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:
Ben Newman
2014-03-04 12:59:55 -05:00
parent 1d27770b40
commit 9c87aef67f
+2 -1
View File
@@ -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() {