2016-06-08 08:11:04 +08:00
|
|
|
/**
|
2017-09-25 04:48:13 +08:00
|
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
2016-06-08 08:11:04 +08:00
|
|
|
*
|
2017-09-25 04:48:13 +08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-06-08 08:11:04 +08:00
|
|
|
*
|
|
|
|
|
* @emails react-core
|
|
|
|
|
*/
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
var reactProdInvariant;
|
|
|
|
|
|
2016-09-07 06:18:42 +08:00
|
|
|
describe('reactProdInvariant', () => {
|
|
|
|
|
beforeEach(() => {
|
2016-12-22 11:07:40 +08:00
|
|
|
jest.resetModules();
|
2017-11-03 03:50:03 +08:00
|
|
|
reactProdInvariant = require('shared/reactProdInvariant').default;
|
2016-06-08 08:11:04 +08:00
|
|
|
});
|
|
|
|
|
|
2016-09-07 06:18:42 +08:00
|
|
|
it('should throw with the correct number of `%s`s in the URL', () => {
|
2016-06-08 08:11:04 +08:00
|
|
|
expect(function() {
|
|
|
|
|
reactProdInvariant(124, 'foo', 'bar');
|
|
|
|
|
}).toThrowError(
|
|
|
|
|
'Minified React error #124; visit ' +
|
2017-03-14 08:05:18 +08:00
|
|
|
'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.',
|
2016-06-08 08:11:04 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(function() {
|
|
|
|
|
reactProdInvariant(20);
|
|
|
|
|
}).toThrowError(
|
|
|
|
|
'Minified React error #20; visit ' +
|
2017-03-14 08:05:18 +08:00
|
|
|
'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.',
|
2016-06-08 08:11:04 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(function() {
|
|
|
|
|
reactProdInvariant(77, '<div>', '&?bar');
|
|
|
|
|
}).toThrowError(
|
|
|
|
|
'Minified React error #77; visit ' +
|
2017-03-14 08:05:18 +08:00
|
|
|
'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.',
|
2016-06-08 08:11:04 +08:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|