Spy on purgeID instead of unmountIDFromEnvironment
Ben Alpert committed
Jan 8, 2014 at 21:48 UTC
2716f388611bacaf3906b92a2d9628318da9338b
1 file changed
+8
-9
src/core/__tests__/ReactCompositeComponent-test.js
+8
-9
@@ -512,7 +512,7 @@ describe('ReactCompositeComponent', function() {
512
var container = document.createElement('div');
513
var innerUnmounted = false;
514
515
- spyOn(ReactComponent, 'unmountIDFromEnvironment').andCallThrough();
515
+ spyOn(ReactMount, 'purgeID').andCallThrough();
516
517
var Component = React.createClass({
518
render: function() {
@@ -523,12 +523,11 @@ describe('ReactCompositeComponent', function() {
523
});
524
var Inner = React.createClass({
525
componentWillUnmount: function() {
526
- // It's important that unmountIDFromEnvironment (which clears
527
- // ReactMount's node cache) be called after any component lifecycle
528
- // methods, because a componentWillMount implementation is likely call
529
- // this.getDOMNode(), which will repopulate the node cache after it's
530
- // been cleared, causing a memory leak.
531
- expect(ReactComponent.unmountIDFromEnvironment.callCount).toBe(0);
526
+ // It's important that ReactMount.purgeID be called after any component
527
+ // lifecycle methods, because a componentWillMount implementation is
528
+ // likely call this.getDOMNode(), which will repopulate the node cache
529
+ // after it's been cleared, causing a memory leak.
530
+ expect(ReactMount.purgeID.callCount).toBe(0);
531
innerUnmounted = true;
532
},
533
render: function() {
@@ -541,8 +540,8 @@ describe('ReactCompositeComponent', function() {
540
expect(innerUnmounted).toBe(true);
541
542
// <Component />, <Inner />, and both <div /> elements each call
544
- // unmountIDFromEnvironment, for a total of 4.
545
- expect(ReactComponent.unmountIDFromEnvironment.callCount).toBe(4);
543
+ // unmountIDFromEnvironment which calls purgeID, for a total of 4.
544
+ expect(ReactMount.purgeID.callCount).toBe(4);
545
});
546
547
it('should detect valid CompositeComponent classes', function() {