@samitouri / QOS-React / commits / c291f8a81e

prop-types(symbols,tests): test for polyfilled Symbol and non-Symbol elements

Raito Bezarius committed Apr 2, 2016 at 14:28 UTC c291f8a81e83b6bb9b7322cc9fdff83954c8e6e2
1 file changed +33
src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
+33
@@ -798,6 +798,39 @@ describe('ReactPropTypes', function() {
798 });
799 });
800
801 + describe('Symbol Type', function() {
802 + it('should warn for non-symbol', function() {
803 + typeCheckFail(
804 + PropTypes.symbol,
805 + 'hello',
806 + 'Invalid prop `testProp` of type `string` supplied to ' +
807 + '`testComponent`, expected `symbol`.'
808 + );
809 + typeCheckFail(
810 + PropTypes.symbol,
811 + function () { },
812 + 'Invalid prop `testProp` of type `function` supplied to ' +
813 + '`testComponent`, expected `symbol`.'
814 + );
815 + typeCheckFail(
816 + PropTypes.symbol,
817 + {
818 + '@@toStringTag': 'Katana'
819 + },
820 + 'Invalid prop `testProp` of type `object` supplied to ' +
821 + '`testComponent`, expected `symbol`.'
822 + );
823 + });
824 +
825 + it('should not warn for a polyfilled Symbol', function() {
826 + var ES6Symbol = require('es6-symbol/polyfill');
827 + var CoreSymbol = require('core-js/library/es6/symbol');
828 +
829 + typeCheckPass(PropTypes.symbol, ES6Symbol('es6-symbol'))
830 + typeCheckPass(PropTypes.symbol, CoreSymbol('core-js'))
831 + });
832 + });
833 +
834 describe('Custom validator', function() {
835 beforeEach(function() {
836 jest.resetModuleRegistry();