Files
yarn/__tests__/constants.js
Nick Olinger 2952f3c85e Fix: Remove devDependencies from list output when environment is production (#4092)
**Summary**

Fixes: #3788.

This PR loads `devDependencies` from the manifest, re-builds the patterns package structure, and filters packages if the `NODE_ENV` is production.

**Test plan**

Added new tests.
2017-08-18 16:33:05 +01:00

28 lines
798 B
JavaScript

/* @flow */
import {getPathKey, isProduction} from '../src/constants.js';
test('getPathKey', () => {
expect(getPathKey('win32', {PATH: 'foobar'})).toBe('PATH');
expect(getPathKey('win32', {Path: 'foobar'})).toBe('Path');
expect(getPathKey('win32', {PaTh: 'foobar'})).toBe('PaTh');
expect(getPathKey('win32', {})).toBe('Path');
expect(getPathKey('linux', {})).toBe('PATH');
expect(getPathKey('darwin', {})).toBe('PATH');
});
describe('isProduction', () => {
const env = {
NODE_ENV: '',
};
test('passing "development" should return false', () => {
env.NODE_ENV = 'development';
expect(isProduction(env)).toBe(false);
});
test('passing "production" should return true', () => {
env.NODE_ENV = 'production';
expect(isProduction(env)).toBe(true);
});
});