Make ReactEmptyComponent-test not swallow logs
Ben Alpert committed
Oct 15, 2015 at 11:51 UTC
19e2cf5ad557422bd04532c56e999d663fd7eb95
1 file changed
+21
-23
src/renderers/shared/reconciler/__tests__/ReactEmptyComponent-test.js
+21
-23
@@ -18,6 +18,8 @@ var TogglingComponent;
18
19
var reactComponentExpect;
20
21
+var log;
22
+
23
describe('ReactEmptyComponent', function() {
24
beforeEach(function() {
25
jest.resetModuleRegistry();
@@ -28,16 +30,18 @@ describe('ReactEmptyComponent', function() {
30
31
reactComponentExpect = require('reactComponentExpect');
32
33
+ log = jasmine.createSpy();
34
+
35
TogglingComponent = React.createClass({
36
getInitialState: function() {
37
return {component: this.props.firstComponent};
38
},
39
componentDidMount: function() {
36
- console.log(ReactDOM.findDOMNode(this));
40
+ log(ReactDOM.findDOMNode(this));
41
this.setState({component: this.props.secondComponent});
42
},
43
componentDidUpdate: function() {
40
- console.log(ReactDOM.findDOMNode(this));
44
+ log(ReactDOM.findDOMNode(this));
45
},
46
render: function() {
47
var Component = this.state.component;
@@ -81,8 +85,6 @@ describe('ReactEmptyComponent', function() {
85
});
86
87
it('should be able to switch between rendering null and a normal tag', () => {
84
- spyOn(console, 'log');
85
-
88
var instance1 =
89
<TogglingComponent
90
firstComponent={null}
@@ -97,17 +99,15 @@ describe('ReactEmptyComponent', function() {
99
ReactTestUtils.renderIntoDocument(instance1);
100
ReactTestUtils.renderIntoDocument(instance2);
101
100
- expect(console.log.argsForCall.length).toBe(4);
101
- expect(console.log.argsForCall[0][0]).toBe(null);
102
- expect(console.log.argsForCall[1][0].tagName).toBe('DIV');
103
- expect(console.log.argsForCall[2][0].tagName).toBe('DIV');
104
- expect(console.log.argsForCall[3][0]).toBe(null);
102
+ expect(log.argsForCall.length).toBe(4);
103
+ expect(log.argsForCall[0][0]).toBe(null);
104
+ expect(log.argsForCall[1][0].tagName).toBe('DIV');
105
+ expect(log.argsForCall[2][0].tagName).toBe('DIV');
106
+ expect(log.argsForCall[3][0]).toBe(null);
107
});
108
109
it('should distinguish between a script placeholder and an actual script tag',
110
() => {
109
- spyOn(console, 'log');
110
-
111
var instance1 =
112
<TogglingComponent
113
firstComponent={null}
@@ -126,19 +126,17 @@ describe('ReactEmptyComponent', function() {
126
ReactTestUtils.renderIntoDocument(instance2);
127
}).not.toThrow();
128
129
- expect(console.log.argsForCall.length).toBe(4);
130
- expect(console.log.argsForCall[0][0]).toBe(null);
131
- expect(console.log.argsForCall[1][0].tagName).toBe('SCRIPT');
132
- expect(console.log.argsForCall[2][0].tagName).toBe('SCRIPT');
133
- expect(console.log.argsForCall[3][0]).toBe(null);
129
+ expect(log.argsForCall.length).toBe(4);
130
+ expect(log.argsForCall[0][0]).toBe(null);
131
+ expect(log.argsForCall[1][0].tagName).toBe('SCRIPT');
132
+ expect(log.argsForCall[2][0].tagName).toBe('SCRIPT');
133
+ expect(log.argsForCall[3][0]).toBe(null);
134
}
135
);
136
137
it('should have getDOMNode return null when multiple layers of composite ' +
138
'components render to the same null placeholder',
139
() => {
140
- spyOn(console, 'log');
141
-
140
var GrandChild = React.createClass({
141
render: function() {
142
return null;
@@ -169,11 +167,11 @@ describe('ReactEmptyComponent', function() {
167
ReactTestUtils.renderIntoDocument(instance2);
168
}).not.toThrow();
169
172
- expect(console.log.argsForCall.length).toBe(4);
173
- expect(console.log.argsForCall[0][0].tagName).toBe('DIV');
174
- expect(console.log.argsForCall[1][0]).toBe(null);
175
- expect(console.log.argsForCall[2][0]).toBe(null);
176
- expect(console.log.argsForCall[3][0].tagName).toBe('DIV');
170
+ expect(log.argsForCall.length).toBe(4);
171
+ expect(log.argsForCall[0][0].tagName).toBe('DIV');
172
+ expect(log.argsForCall[1][0]).toBe(null);
173
+ expect(log.argsForCall[2][0]).toBe(null);
174
+ expect(log.argsForCall[3][0].tagName).toBe('DIV');
175
}
176
);
177