@samitouri / QOS-React-2 / commits / 9c87aef67f

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`.

Ben Newman committed Mar 4, 2014 at 12:59 UTC 9c87aef67f874afc24b3ebaa6f9b71f5fb85dc9b
1 file changed +2 -1
src/utils/__tests__/cloneWithProps-test.js
+2 -1
@@ -24,12 +24,12 @@ require('mock-modules').dontMock('cloneWithProps');
24 var mocks = require('mocks');
25
26 var cloneWithProps = require('cloneWithProps');
27 -var emptyObject = require('emptyObject');
27
28 var React;
29 var ReactTestUtils;
30
31 var onlyChild;
32 +var emptyObject;
33
34 describe('cloneWithProps', function() {
35
@@ -37,6 +37,7 @@ describe('cloneWithProps', function() {
37 React = require('React');
38 ReactTestUtils = require('ReactTestUtils');
39 onlyChild = require('onlyChild');
40 + emptyObject = require('emptyObject');
41 });
42
43 it('should clone a DOM component with new props', function() {