diff --git a/src/browser/server/ReactServerRendering.js b/src/browser/server/ReactServerRendering.js
index 056eca4eac..43f7786d1f 100644
--- a/src/browser/server/ReactServerRendering.js
+++ b/src/browser/server/ReactServerRendering.js
@@ -75,7 +75,8 @@ function renderComponentToStaticMarkup(component) {
transaction = ReactServerRenderingTransaction.getPooled(true);
return transaction.perform(function() {
- return component.mountComponent(id, transaction, 0);
+ var componentInstance = instantiateReactComponent(component);
+ return componentInstance.mountComponent(id, transaction, 0);
}, null);
} finally {
ReactServerRenderingTransaction.release(transaction);
diff --git a/src/browser/ui/dom/components/__tests__/ReactDOMInput-test.js b/src/browser/ui/dom/components/__tests__/ReactDOMInput-test.js
index d2049a6d51..e5405cf21c 100644
--- a/src/browser/ui/dom/components/__tests__/ReactDOMInput-test.js
+++ b/src/browser/ui/dom/components/__tests__/ReactDOMInput-test.js
@@ -29,37 +29,32 @@ describe('ReactDOMInput', function() {
var ReactLink;
var ReactTestUtils;
- var renderTextInput;
-
beforeEach(function() {
React = require('React');
ReactLink = require('ReactLink');
ReactTestUtils = require('ReactTestUtils');
-
- renderTextInput = function(component) {
- var stub = ReactTestUtils.renderIntoDocument(component);
- var node = stub.getDOMNode();
- return node;
- };
});
it('should display `defaultValue` of number 0', function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('0');
});
it('should display "true" for `defaultValue` of `true`', function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('true');
});
it('should display "false" for `defaultValue` of `false`', function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('false');
});
@@ -72,21 +67,24 @@ describe('ReactDOMInput', function() {
};
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('foobar');
});
it('should display `value` of number 0', function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('0');
});
it('should allow setting `value` to `true`', function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('yolo');
@@ -96,7 +94,8 @@ describe('ReactDOMInput', function() {
it("should allow setting `value` to `false`", function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('yolo');
@@ -106,7 +105,8 @@ describe('ReactDOMInput', function() {
it('should allow setting `value` to `objToString`', function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('foo');
@@ -122,7 +122,8 @@ describe('ReactDOMInput', function() {
it('should properly control a value of number `0`', function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
node.value = 'giraffe';
ReactTestUtils.Simulate.change(node);
@@ -131,7 +132,8 @@ describe('ReactDOMInput', function() {
it('should not set a value for submit buttons unnecessarily', function() {
var stub = ;
- var node = renderTextInput(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
// The value shouldn't be '', or else the button will have no text; it
// should have the default "Submit" or "Submit Query" label
@@ -184,7 +186,7 @@ describe('ReactDOMInput', function() {
var link = new ReactLink('yolo', mocks.getMockFunction());
var instance = ;
- React.renderComponent(instance, container);
+ instance = React.renderComponent(instance, container);
expect(instance.getDOMNode().value).toBe('yolo');
expect(link.value).toBe('yolo');
@@ -257,7 +259,7 @@ describe('ReactDOMInput', function() {
var link = new ReactLink(true, mocks.getMockFunction());
var instance = ;
- React.renderComponent(instance, container);
+ instance = React.renderComponent(instance, container);
expect(instance.getDOMNode().checked).toBe(true);
expect(link.value).toBe(true);
diff --git a/src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js b/src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js
index acff91011a..c3f4781c57 100644
--- a/src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js
+++ b/src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js
@@ -28,18 +28,10 @@ describe('ReactDOMSelect', function() {
var ReactLink;
var ReactTestUtils;
- var renderSelect;
-
beforeEach(function() {
React = require('React');
ReactLink = require('ReactLink');
ReactTestUtils = require('ReactTestUtils');
-
- renderSelect = function(component) {
- var stub = ReactTestUtils.renderIntoDocument(component);
- var node = stub.getDOMNode();
- return node;
- };
});
it('should allow setting `defaultValue`', function() {
@@ -49,7 +41,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('giraffe');
@@ -65,7 +58,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('giraffe');
@@ -82,7 +76,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.options[0].selected).toBe(false); // monkey
expect(node.options[1].selected).toBe(true); // giraffe
@@ -103,7 +98,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('giraffe');
@@ -119,7 +115,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.options[0].selected).toBe(false); // monkey
expect(node.options[1].selected).toBe(true); // giraffe
@@ -140,7 +137,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.options[0].selected).toBe(false); // one
expect(node.options[1].selected).toBe(false); // two
@@ -161,7 +159,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.options[0].selected).toBe(false); // monkey
expect(node.options[1].selected).toBe(true); // giraffe
@@ -183,7 +182,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.options[0].selected).toBe(false); // monkey
expect(node.options[1].selected).toBe(true); // giraffe
@@ -204,7 +204,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.options[0].selected).toBe(false); // monkey
expect(node.options[1].selected).toBe(true); // giraffe
@@ -227,7 +228,8 @@ describe('ReactDOMSelect', function() {
;
- var node = renderSelect(stub);
+ stub = ReactTestUtils.renderIntoDocument(stub);
+ var node = stub.getDOMNode();
expect(node.options[0].selected).toBe(false); // monkey
expect(node.options[1].selected).toBe(true); // giraffe
diff --git a/src/browser/ui/dom/components/__tests__/ReactDOMTextarea-test.js b/src/browser/ui/dom/components/__tests__/ReactDOMTextarea-test.js
index 576f21997c..41122d14c0 100644
--- a/src/browser/ui/dom/components/__tests__/ReactDOMTextarea-test.js
+++ b/src/browser/ui/dom/components/__tests__/ReactDOMTextarea-test.js
@@ -40,13 +40,14 @@ describe('ReactDOMTextarea', function() {
var node = stub.getDOMNode();
// Polyfilling the browser's quirky behavior.
node.value = node.innerHTML;
- return node;
+ return stub;
};
});
it('should allow setting `defaultValue`', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('giraffe');
@@ -57,14 +58,16 @@ describe('ReactDOMTextarea', function() {
it('should display `defaultValue` of number 0', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('0');
});
it('should display "false" for `defaultValue` of `false`', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('false');
});
@@ -77,21 +80,24 @@ describe('ReactDOMTextarea', function() {
};
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('foobar');
});
it('should display `value` of number 0', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('0');
});
it('should allow setting `value` to `giraffe`', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('giraffe');
@@ -101,7 +107,8 @@ describe('ReactDOMTextarea', function() {
it('should allow setting `value` to `true`', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('giraffe');
@@ -111,7 +118,8 @@ describe('ReactDOMTextarea', function() {
it('should allow setting `value` to `false`', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('giraffe');
@@ -121,7 +129,8 @@ describe('ReactDOMTextarea', function() {
it('should allow setting `value` to `objToString`', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(node.value).toBe('giraffe');
@@ -136,7 +145,8 @@ describe('ReactDOMTextarea', function() {
it('should properly control a value of number `0`', function() {
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
node.value = 'giraffe';
ReactTestUtils.Simulate.change(node);
@@ -147,7 +157,8 @@ describe('ReactDOMTextarea', function() {
spyOn(console, 'warn');
var stub = ;
- var node = renderTextarea(stub);
+ stub = renderTextarea(stub);
+ var node = stub.getDOMNode();
expect(console.warn.argsForCall.length).toBe(1);
expect(node.value).toBe('giraffe');
@@ -159,14 +170,14 @@ describe('ReactDOMTextarea', function() {
it('should allow numbers as children', function() {
spyOn(console, 'warn');
- var node = renderTextarea();
+ var node = renderTextarea().getDOMNode();
expect(console.warn.argsForCall.length).toBe(1);
expect(node.value).toBe('17');
});
it('should allow booleans as children', function() {
spyOn(console, 'warn');
- var node = renderTextarea();
+ var node = renderTextarea().getDOMNode();
expect(console.warn.argsForCall.length).toBe(1);
expect(node.value).toBe('false');
});
@@ -178,7 +189,7 @@ describe('ReactDOMTextarea', function() {
return "sharkswithlasers";
}
};
- var node = renderTextarea();
+ var node = renderTextarea().getDOMNode();
expect(console.warn.argsForCall.length).toBe(1);
expect(node.value).toBe('sharkswithlasers');
});
@@ -194,12 +205,12 @@ describe('ReactDOMTextarea', function() {
expect(console.warn.argsForCall.length).toBe(1);
- var stub;
+ var node;
expect(function() {
- stub = renderTextarea();
+ node = renderTextarea().getDOMNode();
}).not.toThrow();
- expect(stub.value).toBe('[object Object]');
+ expect(node.value).toBe('[object Object]');
expect(console.warn.argsForCall.length).toBe(2);
});
@@ -209,7 +220,7 @@ describe('ReactDOMTextarea', function() {
var link = new ReactLink('yolo', mocks.getMockFunction());
var instance = ;
- React.renderComponent(instance, container);
+ instance = React.renderComponent(instance, container);
expect(instance.getDOMNode().value).toBe('yolo');
expect(link.value).toBe('yolo');
diff --git a/src/core/__tests__/ReactBind-test.js b/src/core/__tests__/ReactBind-test.js
index ef5b93c3b2..f82e01503d 100644
--- a/src/core/__tests__/ReactBind-test.js
+++ b/src/core/__tests__/ReactBind-test.js
@@ -62,13 +62,13 @@ describe('autobinding', function() {
var instance1 = ;
var mountedInstance1 = ReactTestUtils.renderIntoDocument(instance1);
- var rendered1 = reactComponentExpect(instance1)
+ var rendered1 = reactComponentExpect(mountedInstance1)
.expectRenderedChild()
.instance();
var instance2 = ;
var mountedInstance2 = ReactTestUtils.renderIntoDocument(instance2);
- var rendered2 = reactComponentExpect(instance2)
+ var rendered2 = reactComponentExpect(mountedInstance2)
.expectRenderedChild()
.instance();
@@ -123,7 +123,7 @@ describe('autobinding', function() {
var instance1 = ;
var mountedInstance1 = ReactTestUtils.renderIntoDocument(instance1);
- var rendered1 = reactComponentExpect(instance1)
+ var rendered1 = reactComponentExpect(mountedInstance1)
.expectRenderedChild()
.instance();
diff --git a/src/core/__tests__/ReactComponentLifeCycle-test.js b/src/core/__tests__/ReactComponentLifeCycle-test.js
index ae35b942ee..3f4d2d1524 100644
--- a/src/core/__tests__/ReactComponentLifeCycle-test.js
+++ b/src/core/__tests__/ReactComponentLifeCycle-test.js
@@ -108,11 +108,11 @@ describe('ReactComponentLifeCycle', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
instance.addAnotherField();
expect(instance.state.aField).toBe('asdf');
instance.unmountComponent();
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(typeof instance.state.aField).toBe('undefined');
});
@@ -157,7 +157,7 @@ describe('ReactComponentLifeCycle', function() {
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(_testJournal).toEqual([
'SwitcherParent:getInitialState',
'SwitcherParent:onDOMReady',
@@ -180,11 +180,11 @@ describe('ReactComponentLifeCycle', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
instance.addAnotherField();
expect(instance.state.aField).toBe('asdf');
instance.unmountComponent();
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.state).toBe(null);
});
@@ -203,7 +203,7 @@ describe('ReactComponentLifeCycle', function() {
});
var instance = ;
expect(function() {
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
}).toThrow();
});
@@ -220,7 +220,7 @@ describe('ReactComponentLifeCycle', function() {
});
var instance = ;
expect(function() {
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
}).not.toThrow();
});
@@ -239,7 +239,7 @@ describe('ReactComponentLifeCycle', function() {
});
var instance = ;
expect(function() {
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
}).not.toThrow();
// The return value of getInitialState overrides anything from setState
@@ -403,7 +403,7 @@ describe('ReactComponentLifeCycle', function() {
valueToUseInOnDOMReady="goodbye"
/>;
expect(function() {
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
}).toThrow(
'Invariant Violation: replaceProps(...): You called `setProps` or ' +
'`replaceProps` on a component with a parent. This is an anti-pattern ' +
@@ -497,7 +497,7 @@ describe('ReactComponentLifeCycle', function() {
valueToUseInitially="hello"
valueToUseInOnDOMReady="goodbye"
/>;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.state.stateField).toBe('goodbye');
});
diff --git a/src/core/__tests__/ReactCompositeComponent-test.js b/src/core/__tests__/ReactCompositeComponent-test.js
index f42b0054f9..c5de4a340e 100644
--- a/src/core/__tests__/ReactCompositeComponent-test.js
+++ b/src/core/__tests__/ReactCompositeComponent-test.js
@@ -92,7 +92,7 @@ describe('ReactCompositeComponent', function() {
it('should support rendering to different child types over time', function() {
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
reactComponentExpect(instance)
.expectRenderedChild()
@@ -111,7 +111,7 @@ describe('ReactCompositeComponent', function() {
it('should react to state changes from callbacks', function() {
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
var renderedChild = reactComponentExpect(instance)
.expectRenderedChild()
@@ -125,7 +125,7 @@ describe('ReactCompositeComponent', function() {
it('should rewire refs when rendering to different child types', function() {
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
reactComponentExpect(instance.refs.x).toBeDOMComponentWithTag('a');
instance._toggleActivatedState();
@@ -136,7 +136,7 @@ describe('ReactCompositeComponent', function() {
it('should not cache old DOM nodes when switching constructors', function() {
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
instance.setProps({anchorClassOn: true}); // Warm any cache
instance.setProps({renderAnchor: false}); // Clear out the anchor
// rerender
@@ -168,38 +168,37 @@ describe('ReactCompositeComponent', function() {
});
var instance = ;
- // These are controversial assertions for now, they just exist
- // because existing code depends on these assumptions.
- // These are expected to log a warning. This use case will be deprecated.
- expect(function() {
- instance.methodToBeExplicitlyBound.bind(instance)();
- }).not.toThrow();
- expect(function() {
- instance.methodAutoBound();
- }).not.toThrow();
- expect(function() {
- instance.methodExplicitlyNotBound();
- }).not.toThrow();
-
// Next, prove that once mounted, the scope is bound correctly to the actual
// component.
var mountedInstance = ReactTestUtils.renderIntoDocument(instance);
- expect(console.warn.argsForCall.length).toBe(3);
- // This will result in a warning that has already been issued before.
- var explicitlyBound = instance.methodToBeExplicitlyBound.bind(instance);
- expect(console.warn.argsForCall.length).toBe(3);
- var autoBound = instance.methodAutoBound;
- var explicitlyNotBound = instance.methodExplicitlyNotBound;
+
+ expect(function() {
+ mountedInstance.methodToBeExplicitlyBound.bind(instance)();
+ }).not.toThrow();
+ expect(function() {
+ mountedInstance.methodAutoBound();
+ }).not.toThrow();
+ expect(function() {
+ mountedInstance.methodExplicitlyNotBound();
+ }).not.toThrow();
+
+ expect(console.warn.argsForCall.length).toBe(1);
+ var explicitlyBound = mountedInstance.methodToBeExplicitlyBound.bind(
+ mountedInstance
+ );
+ expect(console.warn.argsForCall.length).toBe(2);
+ var autoBound = mountedInstance.methodAutoBound;
+ var explicitlyNotBound = mountedInstance.methodExplicitlyNotBound;
var context = {};
expect(explicitlyBound.call(context)).toBe(mountedInstance);
expect(autoBound.call(context)).toBe(mountedInstance);
expect(explicitlyNotBound.call(context)).toBe(context);
- expect(explicitlyBound.call(instance)).toBe(mountedInstance);
- expect(autoBound.call(instance)).toBe(mountedInstance);
+ expect(explicitlyBound.call(mountedInstance)).toBe(mountedInstance);
+ expect(autoBound.call(mountedInstance)).toBe(mountedInstance);
// This one is the weird one
- expect(explicitlyNotBound.call(instance)).toBe(mountedInstance);
+ expect(explicitlyNotBound.call(mountedInstance)).toBe(mountedInstance);
});
@@ -214,15 +213,15 @@ describe('ReactCompositeComponent', function() {
});
var instance1 = ;
- ReactTestUtils.renderIntoDocument(instance1);
+ instance1 = ReactTestUtils.renderIntoDocument(instance1);
reactComponentExpect(instance1).scalarPropsEqual({key: 'testKey'});
var instance2 = ;
- ReactTestUtils.renderIntoDocument(instance2);
+ instance2 = ReactTestUtils.renderIntoDocument(instance2);
reactComponentExpect(instance2).scalarPropsEqual({key: 'testKey'});
var instance3 = ;
- ReactTestUtils.renderIntoDocument(instance3);
+ instance3 = ReactTestUtils.renderIntoDocument(instance3);
reactComponentExpect(instance3).scalarPropsEqual({key: null});
});
@@ -238,7 +237,7 @@ describe('ReactCompositeComponent', function() {
var inputProps = {};
var instance1 = Component(inputProps);
- ReactTestUtils.renderIntoDocument(instance1);
+ instance1 = ReactTestUtils.renderIntoDocument(instance1);
expect(instance1.props.key).toBe('testKey');
// We don't mutate the input, just in case the caller wants to do something
@@ -410,7 +409,7 @@ describe('ReactCompositeComponent', function() {
'mounted or mounting components.'
);
- React.renderComponent(instance, container);
+ instance = React.renderComponent(instance, container);
expect(function() {
instance.forceUpdate();
}).not.toThrow();
@@ -435,7 +434,7 @@ describe('ReactCompositeComponent', function() {
expect(ReactCurrentOwner.current).toBe(null);
expect(function() {
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
}).toThrow();
expect(ReactCurrentOwner.current).toBe(null);
@@ -457,7 +456,7 @@ describe('ReactCompositeComponent', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.state.component).toBe(true);
expect(instance.state.mixin).toBe(true);
});
@@ -479,7 +478,7 @@ describe('ReactCompositeComponent', function() {
});
var instance = ;
expect(function() {
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
}).toThrow(
'Invariant Violation: mergeObjectsWithNoDuplicateKeys(): ' +
'Tried to merge two objects with the same key: x'
@@ -498,7 +497,7 @@ describe('ReactCompositeComponent', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.state.occupation).toEqual('clown');
});
@@ -514,7 +513,7 @@ describe('ReactCompositeComponent', function() {
});
var instance = ;
expect(function() {
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
}).toThrow(
'Invariant Violation: Component.getInitialState(): ' +
'must return an object or null'
@@ -559,7 +558,7 @@ describe('ReactCompositeComponent', function() {
).not.toThrow();
instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.state).toEqual({foo: 'bar'});
// Also the other way round should work
@@ -582,7 +581,7 @@ describe('ReactCompositeComponent', function() {
).not.toThrow();
instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.state).toEqual({foo: 'bar'});
// Multiple mixins should be fine too
@@ -600,7 +599,7 @@ describe('ReactCompositeComponent', function() {
).not.toThrow();
instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.state).toEqual({foo: 'bar', x: true});
});
@@ -616,7 +615,7 @@ describe('ReactCompositeComponent', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.state.occupation).toEqual('clown');
});
@@ -632,7 +631,7 @@ describe('ReactCompositeComponent', function() {
});
var instance = ;
expect(function() {
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
}).toThrow(
'Invariant Violation: Component.getInitialState(): ' +
'must return an object or null'
@@ -803,8 +802,7 @@ describe('ReactCompositeComponent', function() {
},
render: function() {
- childInstance = ;
- return childInstance;
+ return ;
}
});
@@ -825,8 +823,8 @@ describe('ReactCompositeComponent', function() {
},
render: function() {
- grandchildInstance = ;
- return grandchildInstance;
+ childInstance = this;
+ return ;
}
});
@@ -837,12 +835,12 @@ describe('ReactCompositeComponent', function() {
},
render: function() {
+ grandchildInstance = this;
return ;
}
});
- var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ ReactTestUtils.renderIntoDocument();
reactComponentExpect(childInstance).scalarContextEqual({foo: 'bar', depth: 0});
reactComponentExpect(grandchildInstance).scalarContextEqual({foo: 'bar', depth: 1});
});
@@ -940,7 +938,7 @@ describe('ReactCompositeComponent', function() {
var instance = React.withContext({foo: 'abc', bar: 123}, function() {
return ;
});
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
reactComponentExpect(instance).scalarContextEqual({foo: 'abc'});
});
@@ -997,7 +995,7 @@ describe('ReactCompositeComponent', function() {
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
instance.replaceProps({foo: "def"});
expect(actualComponentWillReceiveProps).toEqual({foo: 'def'});
expect(actualShouldComponentUpdate).toEqual({foo: 'def'});
@@ -1019,7 +1017,7 @@ describe('ReactCompositeComponent', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.constructor.abc).toBe('def');
expect(Component.abc).toBe('def');
expect(instance.constructor.def).toBe(0);
@@ -1048,7 +1046,7 @@ describe('ReactCompositeComponent', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
expect(instance.constructor.foo).toBe('bar');
expect(Component.foo).toBe('bar');
expect(instance.constructor.abc).toBe('def');
@@ -1132,7 +1130,7 @@ describe('ReactCompositeComponent', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
});
it('should include the mixin keys in even if their values are falsy',
@@ -1153,7 +1151,7 @@ describe('ReactCompositeComponent', function() {
}
});
var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
+ instance = ReactTestUtils.renderIntoDocument(instance);
});
it('should warn if an umounted component is touched', function() {