Files
react/packages/shared/__tests__/reactProdInvariant-test.js
Dan Abramov 21d0c11523 Convert the Source to ES Modules (#11389)
* Update transforms to handle ES modules

* Update Jest to handle ES modules

* Convert react package to ES modules

* Convert react-art package to ES Modules

* Convert react-call-return package to ES Modules

* Convert react-test-renderer package to ES Modules

* Convert react-cs-renderer package to ES Modules

* Convert react-rt-renderer package to ES Modules

* Convert react-noop-renderer package to ES Modules

* Convert react-dom/server to ES modules

* Convert react-dom/{client,events,test-utils} to ES modules

* Convert react-dom/shared to ES modules

* Convert react-native-renderer to ES modules

* Convert react-reconciler to ES modules

* Convert events to ES modules

* Convert shared to ES modules

* Remove CommonJS support from transforms

* Move ReactDOMFB entry point code into react-dom/src

This is clearer because we can use ES imports in it.

* Fix Rollup shim configuration to work with ESM

* Fix incorrect comment

* Exclude external imports without side effects

* Fix ReactDOM FB build

* Remove TODOs I don’t intend to fix yet
2017-11-02 19:50:03 +00:00

48 lines
1.6 KiB
JavaScript

/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
'use strict';
var reactProdInvariant;
describe('reactProdInvariant', () => {
beforeEach(() => {
jest.resetModules();
reactProdInvariant = require('shared/reactProdInvariant').default;
});
it('should throw with the correct number of `%s`s in the URL', () => {
expect(function() {
reactProdInvariant(124, 'foo', 'bar');
}).toThrowError(
'Minified React error #124; visit ' +
'http://facebook.github.io/react/docs/error-decoder.html?invariant=124&args[]=foo&args[]=bar' +
' for the full message or use the non-minified dev environment' +
' for full errors and additional helpful warnings.',
);
expect(function() {
reactProdInvariant(20);
}).toThrowError(
'Minified React error #20; visit ' +
'http://facebook.github.io/react/docs/error-decoder.html?invariant=20' +
' for the full message or use the non-minified dev environment' +
' for full errors and additional helpful warnings.',
);
expect(function() {
reactProdInvariant(77, '<div>', '&?bar');
}).toThrowError(
'Minified React error #77; visit ' +
'http://facebook.github.io/react/docs/error-decoder.html?invariant=77&args[]=%3Cdiv%3E&args[]=%26%3Fbar' +
' for the full message or use the non-minified dev environment' +
' for full errors and additional helpful warnings.',
);
});
});