mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Better simulate Symbol-less environment
This ensures that our tests expecting Symbol not to exist pass.
This commit is contained in:
@@ -17,8 +17,9 @@ var assign = require('Object.assign');
|
||||
|
||||
// The Symbol used to tag the ReactElement type. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var TYPE_SYMBOL = (typeof Symbol === 'function' && Symbol.for &&
|
||||
Symbol.for('react.element')) || 0xeac7;
|
||||
var TYPE_SYMBOL =
|
||||
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) ||
|
||||
0xeac7;
|
||||
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
|
||||
@@ -20,13 +20,15 @@ var ReactTestUtils;
|
||||
|
||||
describe('ReactElement', function() {
|
||||
var ComponentClass;
|
||||
var originalSymbol;
|
||||
|
||||
beforeEach(function() {
|
||||
require('mock-modules').dumpCache();
|
||||
|
||||
// Delete the native Symbol if we have one to ensure we test the
|
||||
// unpolyfilled environment.
|
||||
delete global.Symbol;
|
||||
originalSymbol = global.Symbol;
|
||||
global.Symbol = undefined;
|
||||
|
||||
React = require('React');
|
||||
ReactDOM = require('ReactDOM');
|
||||
@@ -38,6 +40,14 @@ describe('ReactElement', function() {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
global.Symbol = originalSymbol;
|
||||
});
|
||||
|
||||
it('uses the fallback value when in an environment without Symbol', function() {
|
||||
expect(<div />.$$typeof).toBe(0xeac7);
|
||||
});
|
||||
|
||||
it('returns a complete element according to spec', function() {
|
||||
var element = React.createFactory(ComponentClass)();
|
||||
expect(element.type).toBe(ComponentClass);
|
||||
|
||||
Reference in New Issue
Block a user