mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fix stale usage of emptyObject in cloneWithProps-test.
After we run `require('mock-modules').dumpCache()`, the object exported by
the `emptyObject` module will no longer be identical to previously
exported objects, so tests like `expect(component.refs).toBe(emptyObject)`
will fail.
Note that this behavior only manifests itself in tests, because of course
we do not call `dumpCache` in production code.
We could consider storing the `emptyObject` globally to thwart the effects
of `dumpCache`, but it's more idiomatic simply to re-`require` the latest
version of `emptyObject`.
This commit is contained in:
@@ -24,12 +24,12 @@ require('mock-modules').dontMock('cloneWithProps');
|
||||
var mocks = require('mocks');
|
||||
|
||||
var cloneWithProps = require('cloneWithProps');
|
||||
var emptyObject = require('emptyObject');
|
||||
|
||||
var React;
|
||||
var ReactTestUtils;
|
||||
|
||||
var onlyChild;
|
||||
var emptyObject;
|
||||
|
||||
describe('cloneWithProps', function() {
|
||||
|
||||
@@ -37,6 +37,7 @@ describe('cloneWithProps', function() {
|
||||
React = require('React');
|
||||
ReactTestUtils = require('ReactTestUtils');
|
||||
onlyChild = require('onlyChild');
|
||||
emptyObject = require('emptyObject');
|
||||
});
|
||||
|
||||
it('should clone a DOM component with new props', function() {
|
||||
|
||||
Reference in New Issue
Block a user