[fix] Use of process.env.NODE_ENV

Corrects misspelling in a few locations and adds tests for the Platform module.

Close #2006
This commit is contained in:
Elliot Dickison
2021-04-30 11:28:33 -07:00
committed by Nicolas Gallagher
parent 5726d83544
commit e826485622
3 changed files with 20 additions and 2 deletions
@@ -22,7 +22,7 @@ export function hasPointerEvent() {
export function setPointerEvent(bool) {
const pointerCaptureFn = (name) => (id) => {
if (typeof id !== 'number') {
if (process.env.NODE_DEV !== 'production') {
if (process.env.NODE_ENV !== 'production') {
console.error('A pointerId must be passed to "%s"', name);
}
}
@@ -14,4 +14,22 @@ describe('apis/Platform', () => {
).toEqual('web');
});
});
describe('isTesting', () => {
const NODE_ENV_BACKUP = process.env.NODE_ENV;
afterEach(() => {
process.env.NODE_ENV = NODE_ENV_BACKUP;
});
test('true when NODE_ENV is "test"', () => {
process.env.NODE_ENV = 'test';
expect(Platform.isTesting).toEqual(true);
});
test('false when NODE_ENV is not "test"', () => {
process.env.NODE_ENV = 'development';
expect(Platform.isTesting).toEqual(false);
});
});
});
+1 -1
View File
@@ -12,7 +12,7 @@ const Platform = {
OS: 'web',
select: (obj: Object): any => ('web' in obj ? obj.web : obj.default),
get isTesting(): boolean {
if (process.env.NODE_DEV === 'test') {
if (process.env.NODE_ENV === 'test') {
return true;
}
return false;