This commit is contained in:
35
node_modules/@react-dnd/invariant/test/development.spec.ts
generated
vendored
Normal file
35
node_modules/@react-dnd/invariant/test/development.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import invariant from '../src';
|
||||
|
||||
describe('development mode', () => {
|
||||
const OLD_ENV = process.env;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules(); // this is important - it clears the cache
|
||||
process.env = { ...OLD_ENV };
|
||||
delete process.env.NODE_ENV;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env = OLD_ENV;
|
||||
});
|
||||
|
||||
it('works', () => {
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
expect(function() {
|
||||
invariant(true, 'invariant message');
|
||||
}).not.toThrow();
|
||||
|
||||
expect(function() {
|
||||
invariant(false, 'invariant message');
|
||||
}).toThrow(/invariant message/);
|
||||
|
||||
expect(function() {
|
||||
(invariant as any)(true);
|
||||
}).toThrow(/requires an error/i);
|
||||
|
||||
expect(function() {
|
||||
(invariant as any)(false);
|
||||
}).toThrow(/requires an error/i);
|
||||
});
|
||||
});
|
||||
35
node_modules/@react-dnd/invariant/test/production.spec.ts
generated
vendored
Normal file
35
node_modules/@react-dnd/invariant/test/production.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import invariant from '../src';
|
||||
|
||||
describe('production mode', () => {
|
||||
const OLD_ENV = process.env;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules(); // this is important - it clears the cache
|
||||
process.env = { ...OLD_ENV };
|
||||
delete process.env.NODE_ENV;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env = OLD_ENV;
|
||||
});
|
||||
|
||||
it('works', () => {
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
expect(function() {
|
||||
invariant(true, 'invariant message');
|
||||
}).not.toThrow();
|
||||
|
||||
expect(function() {
|
||||
invariant(false, 'invariant message');
|
||||
}).toThrow(/invariant message/);
|
||||
|
||||
expect(function() {
|
||||
(invariant as any)(true);
|
||||
}).not.toThrow();
|
||||
|
||||
expect(function() {
|
||||
(invariant as any)(false);
|
||||
}).toThrow(/minified exception occurred/i);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user