From c291f8a81e83b6bb9b7322cc9fdff83954c8e6e2 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 2 Apr 2016 14:28:08 +0200 Subject: [PATCH] prop-types(symbols,tests): test for polyfilled Symbol and non-Symbol elements --- .../types/__tests__/ReactPropTypes-test.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js index bcc5bce2a5..eea4b7577a 100644 --- a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js +++ b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js @@ -798,6 +798,39 @@ describe('ReactPropTypes', function() { }); }); + describe('Symbol Type', function() { + it('should warn for non-symbol', function() { + typeCheckFail( + PropTypes.symbol, + 'hello', + 'Invalid prop `testProp` of type `string` supplied to ' + + '`testComponent`, expected `symbol`.' + ); + typeCheckFail( + PropTypes.symbol, + function () { }, + 'Invalid prop `testProp` of type `function` supplied to ' + + '`testComponent`, expected `symbol`.' + ); + typeCheckFail( + PropTypes.symbol, + { + '@@toStringTag': 'Katana' + }, + 'Invalid prop `testProp` of type `object` supplied to ' + + '`testComponent`, expected `symbol`.' + ); + }); + + it('should not warn for a polyfilled Symbol', function() { + var ES6Symbol = require('es6-symbol/polyfill'); + var CoreSymbol = require('core-js/library/es6/symbol'); + + typeCheckPass(PropTypes.symbol, ES6Symbol('es6-symbol')) + typeCheckPass(PropTypes.symbol, CoreSymbol('core-js')) + }); + }); + describe('Custom validator', function() { beforeEach(function() { jest.resetModuleRegistry();