Skip to content

Commit e826485

Browse files
elliotdickisonnecolas
authored andcommitted
[fix] Use of process.env.NODE_ENV
Corrects misspelling in a few locations and adds tests for the Platform module. Close #2006
1 parent 5726d83 commit e826485

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

packages/dom-event-testing-library/src/domEnvironment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function hasPointerEvent() {
2222
export function setPointerEvent(bool) {
2323
const pointerCaptureFn = (name) => (id) => {
2424
if (typeof id !== 'number') {
25-
if (process.env.NODE_DEV !== 'production') {
25+
if (process.env.NODE_ENV !== 'production') {
2626
console.error('A pointerId must be passed to "%s"', name);
2727
}
2828
}

packages/react-native-web/src/exports/Platform/__tests__/index-test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,22 @@ describe('apis/Platform', () => {
1414
).toEqual('web');
1515
});
1616
});
17+
18+
describe('isTesting', () => {
19+
const NODE_ENV_BACKUP = process.env.NODE_ENV;
20+
21+
afterEach(() => {
22+
process.env.NODE_ENV = NODE_ENV_BACKUP;
23+
});
24+
25+
test('true when NODE_ENV is "test"', () => {
26+
process.env.NODE_ENV = 'test';
27+
expect(Platform.isTesting).toEqual(true);
28+
});
29+
30+
test('false when NODE_ENV is not "test"', () => {
31+
process.env.NODE_ENV = 'development';
32+
expect(Platform.isTesting).toEqual(false);
33+
});
34+
});
1735
});

packages/react-native-web/src/exports/Platform/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Platform = {
1212
OS: 'web',
1313
select: (obj: Object): any => ('web' in obj ? obj.web : obj.default),
1414
get isTesting(): boolean {
15-
if (process.env.NODE_DEV === 'test') {
15+
if (process.env.NODE_ENV === 'test') {
1616
return true;
1717
}
1818
return false;

0 commit comments

Comments
 (0)