Upgrade to jest-cli@0.9 and use Jasmine2
Paul O’Shannessy committed
Dec 11, 2015 at 11:02 UTC
d8a0b9a662faccfbcca4cb021afed13b86532014
57 files changed
+675
-640
package.json
+1
@@ -99,6 +99,7 @@
99
"<rootDir>/src",
100
"node_modules/fbjs"
101
],
102
+ "testRunner": "node_modules/jest-cli/src/testRunners/jasmine/jasmine2.js",
103
"unmockedModulePathPatterns": [
104
""
105
]
scripts/jest/jest.d.ts
+1
@@ -17,6 +17,7 @@ declare function xit(name: string, fn: any): void;
17
interface Expect {
18
not: Expect
19
toThrow(message?: string): void
20
+ toThrowError(message?: string): void
21
toBe(value: any): void
22
toEqual(value: any): void
23
toBeFalsy(): void
scripts/jest/test-framework-setup.js
+39
-24
@@ -2,34 +2,49 @@
2
3
var env = jasmine.getEnv();
4
5
+var callCount = 0;
6
var oldError = console.error;
7
var newError = function() {
8
+ callCount++;
9
oldError.apply(this, arguments);
8
- var spec = env.currentSpec;
9
- if (spec) {
10
- var expectationResult = new jasmine.ExpectationResult({
11
- passed: false,
12
- message:
13
- 'Expected test not to warn. If the warning is expected, mock it ' +
14
- 'out using spyOn(console, \'error\'); and test that the warning ' +
15
- 'occurs.',
16
- });
17
- spec.addMatcherResult(expectationResult);
18
- }
10
};
20
-console.error = newError;
11
22
-// Make sure console.error is set back at the end of each test, or else the
23
-// above logic won't work
24
-afterEach(function() {
25
- // TODO: Catch test cases that call spyOn() but don't inspect the mock
26
- // properly.
12
+console.error = newError;
13
28
- if (console.error !== newError && !console.error.isSpy) {
29
- var expectationResult = new jasmine.ExpectationResult({
30
- passed: false,
31
- message: 'Test did not tear down console.error mock properly.',
32
- });
33
- env.currentSpec.addMatcherResult(expectationResult);
34
- }
14
+env.beforeEach(() => {
15
+ callCount = 0;
16
+ jasmine.addMatchers({
17
+ toBeReset() {
18
+ return {
19
+ compare(actual) {
20
+ // TODO: Catch test cases that call spyOn() but don't inspect the mock
21
+ // properly.
22
+ if (actual !== newError && !jasmine.isSpy(actual)) {
23
+ return {
24
+ pass: false,
25
+ message: 'Test did not tear down console.error mock properly.',
26
+ };
27
+ }
28
+ return {pass: true};
29
+ },
30
+ };
31
+ },
32
+ toNotHaveBeenCalled() {
33
+ return {
34
+ compare(actual) {
35
+ return {
36
+ pass: callCount === 0,
37
+ message:
38
+ 'Expected test not to warn. If the warning is expected, mock ' +
39
+ 'it out using spyOn(console, \'error\'); and test that the ' +
40
+ 'warning occurs.',
41
+ };
42
+ },
43
+ };
44
+ },
45
+ });
46
+});
47
+env.afterEach(() => {
48
+ expect(console.error).toBeReset();
49
+ expect(console.error).toNotHaveBeenCalled();
50
});
src/addons/__tests__/ReactFragment-test.js
+11
-11
@@ -31,7 +31,7 @@ describe('ReactFragment', function() {
31
};
32
var element = <div>{[children]}</div>;
33
var container = document.createElement('div');
34
- expect(() => ReactDOM.render(element, container)).toThrow(
34
+ expect(() => ReactDOM.render(element, container)).toThrowError(
35
'Objects are not valid as a React child (found: object with keys ' +
36
'{x, y, z}). If you meant to render a collection of children, use an ' +
37
'array instead or wrap the object using createFragment(object) from ' +
@@ -51,7 +51,7 @@ describe('ReactFragment', function() {
51
}
52
}
53
var container = document.createElement('div');
54
- expect(() => ReactDOM.render(<Foo />, container)).toThrow(
54
+ expect(() => ReactDOM.render(<Foo />, container)).toThrowError(
55
'Objects are not valid as a React child (found: object with keys ' +
56
'{a, b, c}). If you meant to render a collection of children, use an ' +
57
'array instead or wrap the object using createFragment(object) from ' +
@@ -62,7 +62,7 @@ describe('ReactFragment', function() {
62
it('should throw if a plain object looks like an old element', function() {
63
var oldEl = {_isReactElement: true, type: 'span', props: {}};
64
var container = document.createElement('div');
65
- expect(() => ReactDOM.render(<div>{oldEl}</div>, container)).toThrow(
65
+ expect(() => ReactDOM.render(<div>{oldEl}</div>, container)).toThrowError(
66
'Objects are not valid as a React child (found: object with keys ' +
67
'{_isReactElement, type, props}). It looks like you\'re using an ' +
68
'element created by a different version of React. Make sure to use ' +
@@ -75,8 +75,8 @@ describe('ReactFragment', function() {
75
76
ReactFragment.create({1: <span />, 2: <span />});
77
78
- expect(console.error.argsForCall.length).toBe(1);
79
- expect(console.error.argsForCall[0][0]).toContain(
78
+ expect(console.error.calls.count()).toBe(1);
79
+ expect(console.error.calls.argsFor(0)[0]).toContain(
80
'Child objects should have non-numeric keys so ordering is preserved.'
81
);
82
});
@@ -84,8 +84,8 @@ describe('ReactFragment', function() {
84
it('should warn if passing null to createFragment', function() {
85
spyOn(console, 'error');
86
ReactFragment.create(null);
87
- expect(console.error.calls.length).toBe(1);
88
- expect(console.error.argsForCall[0][0]).toContain(
87
+ expect(console.error.calls.count()).toBe(1);
88
+ expect(console.error.calls.argsFor(0)[0]).toContain(
89
'React.addons.createFragment only accepts a single object.'
90
);
91
});
@@ -93,8 +93,8 @@ describe('ReactFragment', function() {
93
it('should warn if passing an array to createFragment', function() {
94
spyOn(console, 'error');
95
ReactFragment.create([]);
96
- expect(console.error.calls.length).toBe(1);
97
- expect(console.error.argsForCall[0][0]).toContain(
96
+ expect(console.error.calls.count()).toBe(1);
97
+ expect(console.error.calls.argsFor(0)[0]).toContain(
98
'React.addons.createFragment only accepts a single object.'
99
);
100
});
@@ -102,8 +102,8 @@ describe('ReactFragment', function() {
102
it('should warn if passing a ReactElement to createFragment', function() {
103
spyOn(console, 'error');
104
ReactFragment.create(<div />);
105
- expect(console.error.calls.length).toBe(1);
106
- expect(console.error.argsForCall[0][0]).toContain(
105
+ expect(console.error.calls.count()).toBe(1);
106
+ expect(console.error.calls.argsFor(0)[0]).toContain(
107
'React.addons.createFragment does not accept a ReactElement without a ' +
108
'wrapper object.'
109
);
src/addons/__tests__/renderSubtreeIntoContainer-test.js
+1
-1
@@ -88,7 +88,7 @@ describe('renderSubtreeIntoContainer', function() {
88
componentDidMount: function() {
89
expect(function() {
90
renderSubtreeIntoContainer(<Parent />, <Component />, portal);
91
- }).toThrow('parentComponentmust be a valid React Component');
91
+ }).toThrowError('parentComponentmust be a valid React Component');
92
},
93
});
94
});
src/addons/__tests__/update-test.js
+11
-11
@@ -25,13 +25,13 @@ describe('update', function() {
25
expect(obj).toEqual([1]);
26
});
27
it('only pushes an array', function() {
28
- expect(update.bind(null, [], {$push: 7})).toThrow(
28
+ expect(update.bind(null, [], {$push: 7})).toThrowError(
29
'update(): expected spec of $push to be an array; got 7. Did you ' +
30
'forget to wrap your parameter in an array?'
31
);
32
});
33
it('only pushes unto an array', function() {
34
- expect(update.bind(null, 1, {$push: 7})).toThrow(
34
+ expect(update.bind(null, 1, {$push: 7})).toThrowError(
35
'update(): expected target of $push to be an array; got 1.'
36
);
37
});
@@ -47,13 +47,13 @@ describe('update', function() {
47
expect(obj).toEqual([1]);
48
});
49
it('only unshifts an array', function() {
50
- expect(update.bind(null, [], {$unshift: 7})).toThrow(
50
+ expect(update.bind(null, [], {$unshift: 7})).toThrowError(
51
'update(): expected spec of $unshift to be an array; got 7. Did you ' +
52
'forget to wrap your parameter in an array?'
53
);
54
});
55
it('only unshifts unto an array', function() {
56
- expect(update.bind(null, 1, {$unshift: 7})).toThrow(
56
+ expect(update.bind(null, 1, {$unshift: 7})).toThrowError(
57
'update(): expected target of $unshift to be an array; got 1.'
58
);
59
});
@@ -69,17 +69,17 @@ describe('update', function() {
69
expect(obj).toEqual([1, 4, 3]);
70
});
71
it('only splices an array of arrays', function() {
72
- expect(update.bind(null, [], {$splice: 1})).toThrow(
72
+ expect(update.bind(null, [], {$splice: 1})).toThrowError(
73
'update(): expected spec of $splice to be an array of arrays; got 1. ' +
74
'Did you forget to wrap your parameters in an array?'
75
);
76
- expect(update.bind(null, [], {$splice: [1]})).toThrow(
76
+ expect(update.bind(null, [], {$splice: [1]})).toThrowError(
77
'update(): expected spec of $splice to be an array of arrays; got 1. ' +
78
'Did you forget to wrap your parameters in an array?'
79
);
80
});
81
it('only splices unto an array', function() {
82
- expect(update.bind(null, 1, {$splice: 7})).toThrow(
82
+ expect(update.bind(null, 1, {$splice: 7})).toThrowError(
83
'Expected $splice target to be an array; got 1'
84
);
85
});
@@ -95,12 +95,12 @@ describe('update', function() {
95
expect(obj).toEqual({a: 'b'});
96
});
97
it('only merges with an object', function() {
98
- expect(update.bind(null, {}, {$merge: 7})).toThrow(
98
+ expect(update.bind(null, {}, {$merge: 7})).toThrowError(
99
'update(): $merge expects a spec of type \'object\'; got 7'
100
);
101
});
102
it('only merges with an object', function() {
103
- expect(update.bind(null, 7, {$merge: {a: 'b'}})).toThrow(
103
+ expect(update.bind(null, 7, {$merge: {a: 'b'}})).toThrowError(
104
'update(): $merge expects a target of type \'object\'; got 7'
105
);
106
});
@@ -130,7 +130,7 @@ describe('update', function() {
130
expect(obj).toEqual({v: 2});
131
});
132
it('only applies a function', function() {
133
- expect(update.bind(null, 2, {$apply: 123})).toThrow(
133
+ expect(update.bind(null, 2, {$apply: 123})).toThrowError(
134
'update(): expected spec of $apply to be a function; got 123.'
135
);
136
});
@@ -170,7 +170,7 @@ describe('update', function() {
170
});
171
172
it('should require a command', function() {
173
- expect(update.bind(null, {a: 'b'}, {a: 'c'})).toThrow(
173
+ expect(update.bind(null, {a: 'b'}, {a: 'c'})).toThrowError(
174
'update(): You provided a key path to update() that did not contain ' +
175
'one of $push, $unshift, $splice, $set, $merge, $apply. Did you ' +
176
'forget to include {$set: ...}?'
src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js
+3
-3
@@ -45,7 +45,7 @@ describe('ReactCSSTransitionGroup', function() {
45
);
46
47
// Warning about the missing transitionLeaveTimeout prop
48
- expect(console.error.argsForCall.length).toBe(1);
48
+ expect(console.error.calls.count()).toBe(1);
49
});
50
51
it('should not warn if timeouts is zero', function() {
@@ -61,7 +61,7 @@ describe('ReactCSSTransitionGroup', function() {
61
container
62
);
63
64
- expect(console.error.argsForCall.length).toBe(0);
64
+ expect(console.error.calls.count()).toBe(0);
65
});
66
67
it('should clean-up silently after the timeout elapses', function() {
@@ -103,7 +103,7 @@ describe('ReactCSSTransitionGroup', function() {
103
}
104
105
// No warnings
106
- expect(console.error.argsForCall.length).toBe(0);
106
+ expect(console.error.calls.count()).toBe(0);
107
108
// The leaving child has been removed
109
expect(ReactDOM.findDOMNode(a).childNodes.length).toBe(1);
src/isomorphic/children/__tests__/ReactChildren-test.js
+13
-13
@@ -23,7 +23,7 @@ describe('ReactChildren', function() {
23
});
24
25
it('should support identity for simple', function() {
26
- var callback = jasmine.createSpy().andCallFake(function(kid, index) {
26
+ var callback = jasmine.createSpy().and.callFake(function(kid, index) {
27
return kid;
28
});
29
@@ -35,14 +35,14 @@ describe('ReactChildren', function() {
35
var instance = <div>{simpleKid}</div>;
36
ReactChildren.forEach(instance.props.children, callback);
37
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
38
- callback.reset();
38
+ callback.calls.reset();
39
var mappedChildren = ReactChildren.map(instance.props.children, callback);
40
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
41
expect(mappedChildren[0]).toEqual(<span key=".$simple" />);
42
});
43
44
it('should treat single arrayless child as being in array', function() {
45
- var callback = jasmine.createSpy().andCallFake(function(kid, index) {
45
+ var callback = jasmine.createSpy().and.callFake(function(kid, index) {
46
return kid;
47
});
48
@@ -50,14 +50,14 @@ describe('ReactChildren', function() {
50
var instance = <div>{simpleKid}</div>;
51
ReactChildren.forEach(instance.props.children, callback);
52
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
53
- callback.reset();
53
+ callback.calls.reset();
54
var mappedChildren = ReactChildren.map(instance.props.children, callback);
55
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
56
expect(mappedChildren[0]).toEqual(<span key=".0" />);
57
});
58
59
it('should treat single child in array as expected', function() {
60
- var callback = jasmine.createSpy().andCallFake(function(kid, index) {
60
+ var callback = jasmine.createSpy().and.callFake(function(kid, index) {
61
return kid;
62
});
63
@@ -65,7 +65,7 @@ describe('ReactChildren', function() {
65
var instance = <div>{[simpleKid]}</div>;
66
ReactChildren.forEach(instance.props.children, callback);
67
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
68
- callback.reset();
68
+ callback.calls.reset();
69
var mappedChildren = ReactChildren.map(instance.props.children, callback);
70
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
71
expect(mappedChildren[0]).toEqual(<span key=".$simple" />);
@@ -124,7 +124,7 @@ describe('ReactChildren', function() {
124
<span />, // Map from null to something.
125
<div key="keyFour" />,
126
];
127
- var callback = jasmine.createSpy().andCallFake(function(kid, index) {
127
+ var callback = jasmine.createSpy().and.callFake(function(kid, index) {
128
return mapped[index];
129
});
130
@@ -144,11 +144,11 @@ describe('ReactChildren', function() {
144
expect(callback).toHaveBeenCalledWith(two, 2);
145
expect(callback).toHaveBeenCalledWith(three, 3);
146
expect(callback).toHaveBeenCalledWith(four, 4);
147
- callback.reset();
147
+ callback.calls.reset();
148
149
var mappedChildren =
150
ReactChildren.map(instance.props.children, callback);
151
- expect(callback.calls.length).toBe(5);
151
+ expect(callback.calls.count()).toBe(5);
152
expect(ReactChildren.count(mappedChildren)).toBe(4);
153
// Keys default to indices.
154
expect([
@@ -190,7 +190,7 @@ describe('ReactChildren', function() {
190
var fourMapped = <div key="keyFour" />;
191
var fiveMapped = <div />;
192
193
- var callback = jasmine.createSpy().andCallFake(function(kid, index) {
193
+ var callback = jasmine.createSpy().and.callFake(function(kid, index) {
194
return index === 0 ? zeroMapped :
195
index === 1 ? twoMapped :
196
index === 2 ? fourMapped : fiveMapped;
@@ -216,15 +216,15 @@ describe('ReactChildren', function() {
216
]);
217
218
ReactChildren.forEach(instance.props.children, callback);
219
- expect(callback.calls.length).toBe(4);
219
+ expect(callback.calls.count()).toBe(4);
220
expect(callback).toHaveBeenCalledWith(frag[0], 0);
221
expect(callback).toHaveBeenCalledWith(frag[1], 1);
222
expect(callback).toHaveBeenCalledWith(frag[2], 2);
223
expect(callback).toHaveBeenCalledWith(frag[3], 3);
224
- callback.reset();
224
+ callback.calls.reset();
225
226
var mappedChildren = ReactChildren.map(instance.props.children, callback);
227
- expect(callback.calls.length).toBe(4);
227
+ expect(callback.calls.count()).toBe(4);
228
expect(callback).toHaveBeenCalledWith(frag[0], 0);
229
expect(callback).toHaveBeenCalledWith(frag[1], 1);
230
expect(callback).toHaveBeenCalledWith(frag[2], 2);
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
+10
-10
@@ -149,8 +149,8 @@ describe('ReactContextValidator', function() {
149
150
ReactTestUtils.renderIntoDocument(<Component />);
151
152
- expect(console.error.argsForCall.length).toBe(1);
153
- expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe(
152
+ expect(console.error.calls.count()).toBe(1);
153
+ expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
154
'Warning: Failed context type: ' +
155
'Required context `foo` was not specified in `Component`.\n' +
156
' in Component (at **)'
@@ -177,7 +177,7 @@ describe('ReactContextValidator', function() {
177
);
178
179
// Previous call should not error
180
- expect(console.error.argsForCall.length).toBe(1);
180
+ expect(console.error.calls.count()).toBe(1);
181
182
var ComponentInFooNumberContext = React.createClass({
183
childContextTypes: {
@@ -197,8 +197,8 @@ describe('ReactContextValidator', function() {
197
198
ReactTestUtils.renderIntoDocument(<ComponentInFooNumberContext fooValue={123} />);
199
200
- expect(console.error.argsForCall.length).toBe(2);
201
- expect(normalizeCodeLocInfo(console.error.argsForCall[1][0])).toBe(
200
+ expect(console.error.calls.count()).toBe(2);
201
+ expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
202
'Warning: Failed context type: ' +
203
'Invalid context `foo` of type `number` supplied ' +
204
'to `Component`, expected `string`.\n' +
@@ -226,8 +226,8 @@ describe('ReactContextValidator', function() {
226
});
227
228
ReactTestUtils.renderIntoDocument(<Component testContext={{bar: 123}} />);
229
- expect(console.error.argsForCall.length).toBe(1);
230
- expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe(
229
+ expect(console.error.calls.count()).toBe(1);
230
+ expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
231
'Warning: Failed childContext type: ' +
232
'Required child context `foo` was not specified in `Component`.\n' +
233
' in Component (at **)'
@@ -235,8 +235,8 @@ describe('ReactContextValidator', function() {
235
236
ReactTestUtils.renderIntoDocument(<Component testContext={{foo: 123}} />);
237
238
- expect(console.error.argsForCall.length).toBe(2);
239
- expect(normalizeCodeLocInfo(console.error.argsForCall[1][0])).toBe(
238
+ expect(console.error.calls.count()).toBe(2);
239
+ expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
240
'Warning: Failed childContext type: ' +
241
'Invalid child context `foo` of type `number` ' +
242
'supplied to `Component`, expected `string`.\n' +
@@ -252,7 +252,7 @@ describe('ReactContextValidator', function() {
252
);
253
254
// Previous calls should not log errors
255
- expect(console.error.argsForCall.length).toBe(2);
255
+ expect(console.error.calls.count()).toBe(2);
256
});
257
258
});
src/isomorphic/classic/class/__tests__/ReactBind-test.js
+3
-3
@@ -132,8 +132,8 @@ describe('autobinding', function() {
132
133
ReactTestUtils.renderIntoDocument(<TestBindComponent />);
134
135
- expect(console.error.argsForCall.length).toBe(1);
136
- expect(console.error.argsForCall[0][0]).toBe(
135
+ expect(console.error.calls.count()).toBe(1);
136
+ expect(console.error.calls.argsFor(0)[0]).toBe(
137
'Warning: bind(): You are binding a component method to the component. ' +
138
'React does this for you automatically in a high-performance ' +
139
'way, so you can safely remove this call. See TestBindComponent'
@@ -160,7 +160,7 @@ describe('autobinding', function() {
160
161
ReactTestUtils.renderIntoDocument(<TestBindComponent />);
162
163
- expect(console.error.argsForCall.length).toBe(0);
163
+ expect(console.error.calls.count()).toBe(0);
164
});
165
166
});
src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js
+2
-2
@@ -203,7 +203,7 @@ describe('autobind optout', function() {
203
204
ReactTestUtils.renderIntoDocument(<TestBindComponent />);
205
206
- expect(console.error.argsForCall.length).toBe(0);
206
+ expect(console.error.calls.count()).toBe(0);
207
});
208
209
it('does not warn if you pass an manually bound method to setState', function() {
@@ -227,7 +227,7 @@ describe('autobind optout', function() {
227
228
ReactTestUtils.renderIntoDocument(<TestBindComponent />);
229
230
- expect(console.error.argsForCall.length).toBe(0);
230
+ expect(console.error.calls.count()).toBe(0);
231
});
232
233
});
src/isomorphic/classic/class/__tests__/ReactClass-test.js
+16
-16
@@ -26,7 +26,7 @@ describe('ReactClass-spec', function() {
26
it('should throw when `render` is not specified', function() {
27
expect(function() {
28
React.createClass({});
29
- }).toThrow(
29
+ }).toThrowError(
30
'createClass(...): Class specification must implement a `render` method.'
31
);
32
});
@@ -123,8 +123,8 @@ describe('ReactClass-spec', function() {
123
return <div />;
124
},
125
});
126
- expect(console.error.argsForCall.length).toBe(1);
127
- expect(console.error.argsForCall[0][0]).toBe(
126
+ expect(console.error.calls.count()).toBe(1);
127
+ expect(console.error.calls.argsFor(0)[0]).toBe(
128
'Warning: A component has a method called componentShouldUpdate(). Did you ' +
129
'mean shouldComponentUpdate()? The name is phrased as a question ' +
130
'because the function is expected to return a value.'
@@ -139,8 +139,8 @@ describe('ReactClass-spec', function() {
139
return <div />;
140
},
141
});
142
- expect(console.error.argsForCall.length).toBe(2);
143
- expect(console.error.argsForCall[1][0]).toBe(
142
+ expect(console.error.calls.count()).toBe(2);
143
+ expect(console.error.calls.argsFor(1)[0]).toBe(
144
'Warning: NamedComponent has a method called componentShouldUpdate(). Did you ' +
145
'mean shouldComponentUpdate()? The name is phrased as a question ' +
146
'because the function is expected to return a value.'
@@ -157,8 +157,8 @@ describe('ReactClass-spec', function() {
157
return <div />;
158
},
159
});
160
- expect(console.error.argsForCall.length).toBe(1);
161
- expect(console.error.argsForCall[0][0]).toBe(
160
+ expect(console.error.calls.count()).toBe(1);
161
+ expect(console.error.calls.argsFor(0)[0]).toBe(
162
'Warning: A component has a method called componentWillRecieveProps(). Did you ' +
163
'mean componentWillReceiveProps()?'
164
);
@@ -179,7 +179,7 @@ describe('ReactClass-spec', function() {
179
return <span />;
180
},
181
});
182
- }).toThrow(
182
+ }).toThrowError(
183
'ReactClass: You are attempting to define a reserved property, ' +
184
'`getDefaultProps`, that shouldn\'t be on the "statics" key. Define ' +
185
'it as an instance property instead; it will still be accessible on ' +
@@ -206,20 +206,20 @@ describe('ReactClass-spec', function() {
206
return <div />;
207
},
208
});
209
- expect(console.error.argsForCall.length).toBe(4);
210
- expect(console.error.argsForCall[0][0]).toBe(
209
+ expect(console.error.calls.count()).toBe(4);
210
+ expect(console.error.calls.argsFor(0)[0]).toBe(
211
'createClass(...): `mixins` is now a static property and should ' +
212
'be defined inside "statics".'
213
);
214
- expect(console.error.argsForCall[1][0]).toBe(
214
+ expect(console.error.calls.argsFor(1)[0]).toBe(
215
'createClass(...): `propTypes` is now a static property and should ' +
216
'be defined inside "statics".'
217
);
218
- expect(console.error.argsForCall[2][0]).toBe(
218
+ expect(console.error.calls.argsFor(2)[0]).toBe(
219
'createClass(...): `contextTypes` is now a static property and ' +
220
'should be defined inside "statics".'
221
);
222
- expect(console.error.argsForCall[3][0]).toBe(
222
+ expect(console.error.calls.argsFor(3)[0]).toBe(
223
'createClass(...): `childContextTypes` is now a static property and ' +
224
'should be defined inside "statics".'
225
);
@@ -314,7 +314,7 @@ describe('ReactClass-spec', function() {
314
var instance = <Component />;
315
expect(function() {
316
instance = ReactTestUtils.renderIntoDocument(instance);
317
- }).toThrow(
317
+ }).toThrowError(
318
'Component.getInitialState(): must return an object or null'
319
);
320
});
@@ -343,8 +343,8 @@ describe('ReactClass-spec', function() {
343
});
344
345
expect(() => Component()).toThrow();
346
- expect(console.error.argsForCall.length).toBe(1);
347
- expect(console.error.argsForCall[0][0]).toBe(
346
+ expect(console.error.calls.count()).toBe(1);
347
+ expect(console.error.calls.argsFor(0)[0]).toBe(
348
'Warning: Something is calling a React component directly. Use a ' +
349
'factory or JSX instead. See: https://fb.me/react-legacyfactory'
350
);
src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js
+7
-7
@@ -155,12 +155,12 @@ describe('ReactClass-mixin', function() {
155
156
it('should override mixin prop types with class prop types', function() {
157
// Sanity check...
158
- expect(componentPropValidator).toNotBe(mixinPropValidator);
158
+ expect(componentPropValidator).not.toBe(mixinPropValidator);
159
// Actually check...
160
expect(TestComponentWithPropTypes.propTypes)
161
.toBeDefined();
162
expect(TestComponentWithPropTypes.propTypes.value)
163
- .toNotBe(mixinPropValidator);
163
+ .not.toBe(mixinPropValidator);
164
expect(TestComponentWithPropTypes.propTypes.value)
165
.toBe(componentPropValidator);
166
});
@@ -205,7 +205,7 @@ describe('ReactClass-mixin', function() {
205
var instance = <Component />;
206
expect(function() {
207
instance = ReactTestUtils.renderIntoDocument(instance);
208
- }).toThrow(
208
+ }).toThrowError(
209
'mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the ' +
210
'same key: `x`. This conflict may be due to a mixin; in particular, ' +
211
'this may be caused by two getInitialState() or getDefaultProps() ' +
@@ -276,7 +276,7 @@ describe('ReactClass-mixin', function() {
276
return <span />;
277
},
278
});
279
- }).toThrow(
279
+ }).toThrowError(
280
'ReactClass: You are attempting to define `abc` on your component more ' +
281
'than once. This conflict may be due to a mixin.'
282
);
@@ -304,7 +304,7 @@ describe('ReactClass-mixin', function() {
304
return <span />;
305
},
306
});
307
- }).toThrow(
307
+ }).toThrowError(
308
'ReactClass: You are attempting to define `abc` on your component ' +
309
'more than once. This conflict may be due to a mixin.'
310
);
@@ -319,7 +319,7 @@ describe('ReactClass-mixin', function() {
319
return <span />;
320
},
321
});
322
- }).toThrow(
322
+ }).toThrowError(
323
'ReactClass: You\'re attempting to use a component as a mixin. ' +
324
'Instead, just use a regular object.'
325
);
@@ -340,7 +340,7 @@ describe('ReactClass-mixin', function() {
340
return <span />;
341
},
342
});
343
- }).toThrow(
343
+ }).toThrowError(
344
'ReactClass: You\'re attempting to use a component class or function ' +
345
'as a mixin. Instead, just use a regular object.'
346
);
src/isomorphic/classic/element/__tests__/ReactElement-test.js
+12
-12
@@ -76,10 +76,10 @@ describe('ReactElement', function() {
76
);
77
},
78
});
79
- expect(console.error.calls.length).toBe(0);
79
+ expect(console.error.calls.count()).toBe(0);
80
ReactDOM.render(<Parent />, container);
81
- expect(console.error.calls.length).toBe(1);
82
- expect(console.error.argsForCall[0][0]).toContain(
81
+ expect(console.error.calls.count()).toBe(1);
82
+ expect(console.error.calls.argsFor(0)[0]).toContain(
83
'Child: `key` is not a prop. Trying to access it will result ' +
84
'in `undefined` being returned. If you need to access the same ' +
85
'value within the child component, you should pass it as a different ' +
@@ -104,10 +104,10 @@ describe('ReactElement', function() {
104
);
105
},
106
});
107
- expect(console.error.calls.length).toBe(0);
107
+ expect(console.error.calls.count()).toBe(0);
108
ReactDOM.render(<Parent />, container);
109
- expect(console.error.calls.length).toBe(1);
110
- expect(console.error.argsForCall[0][0]).toContain(
109
+ expect(console.error.calls.count()).toBe(1);
110
+ expect(console.error.calls.argsFor(0)[0]).toContain(
111
'Child: `ref` is not a prop. Trying to access it will result ' +
112
'in `undefined` being returned. If you need to access the same ' +
113
'value within the child component, you should pass it as a different ' +
@@ -208,7 +208,7 @@ describe('ReactElement', function() {
208
children: 'text',
209
}, a);
210
expect(element.props.children).toBe(a);
211
- expect(console.error.argsForCall.length).toBe(0);
211
+ expect(console.error.calls.count()).toBe(0);
212
});
213
214
it('does not override children if no rest args are provided', function() {
@@ -217,7 +217,7 @@ describe('ReactElement', function() {
217
children: 'text',
218
});
219
expect(element.props.children).toBe('text');
220
- expect(console.error.argsForCall.length).toBe(0);
220
+ expect(console.error.calls.count()).toBe(0);
221
});
222
223
it('overrides children if null is provided as an argument', function() {
@@ -226,7 +226,7 @@ describe('ReactElement', function() {
226
children: 'text',
227
}, null);
228
expect(element.props.children).toBe(null);
229
- expect(console.error.argsForCall.length).toBe(0);
229
+ expect(console.error.calls.count()).toBe(0);
230
});
231
232
it('overrides children if undefined is provided as an argument', function() {
@@ -248,7 +248,7 @@ describe('ReactElement', function() {
248
var c = 3;
249
var element = React.createFactory(ComponentClass)(null, a, b, c);
250
expect(element.props.children).toEqual([1, 2, 3]);
251
- expect(console.error.argsForCall.length).toBe(0);
251
+ expect(console.error.calls.count()).toBe(0);
252
});
253
254
// NOTE: We're explicitly not using JSX here. This is intended to test
@@ -272,7 +272,7 @@ describe('ReactElement', function() {
272
273
var element = React.createElement(StaticMethodComponentClass);
274
expect(element.type.someStaticMethod()).toBe('someReturnValue');
275
- expect(console.error.argsForCall.length).toBe(0);
275
+ expect(console.error.calls.count()).toBe(0);
276
});
277
278
// NOTE: We're explicitly not using JSX here. This is intended to test
@@ -440,7 +440,7 @@ describe('ReactElement', function() {
440
});
441
var test = ReactTestUtils.renderIntoDocument(<Test value={+undefined} />);
442
expect(test.props.value).toBeNaN();
443
- expect(console.error.argsForCall.length).toBe(0);
443
+ expect(console.error.calls.count()).toBe(0);
444
});
445
446
// NOTE: We're explicitly not using JSX here. This is intended to test
src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
+9
-9
@@ -71,8 +71,8 @@ describe('ReactElementClone', function() {
71
React.cloneElement('div', {foo: 1});
72
expect(console.error).not.toHaveBeenCalled();
73
React.cloneElement('div', Object.create({foo: 1}));
74
- expect(console.error.argsForCall.length).toBe(1);
75
- expect(console.error.argsForCall[0][0]).toContain(
74
+ expect(console.error.calls.count()).toBe(1);
75
+ expect(console.error.calls.argsFor(0)[0]).toContain(
76
'React.cloneElement(...): Expected props argument to be a plain object. ' +
77
'Properties defined in its prototype chain will be ignored.'
78
);
@@ -213,8 +213,8 @@ describe('ReactElementClone', function() {
213
214
React.cloneElement(<div />, null, [<div />, <div />]);
215
216
- expect(console.error.argsForCall.length).toBe(1);
217
- expect(console.error.argsForCall[0][0]).toContain(
216
+ expect(console.error.calls.count()).toBe(1);
217
+ expect(console.error.calls.argsFor(0)[0]).toContain(
218
'Each child in an array or iterator should have a unique "key" prop.'
219
);
220
});
@@ -224,7 +224,7 @@ describe('ReactElementClone', function() {
224
225
React.cloneElement(<div />, null, [<div key="#1" />, <div key="#2" />]);
226
227
- expect(console.error.argsForCall.length).toBe(0);
227
+ expect(console.error.calls.count()).toBe(0);
228
});
229
230
it('does not warn when the element is directly in rest args', function() {
@@ -232,7 +232,7 @@ describe('ReactElementClone', function() {
232
233
React.cloneElement(<div />, null, <div />, <div />);
234
235
- expect(console.error.argsForCall.length).toBe(0);
235
+ expect(console.error.calls.count()).toBe(0);
236
});
237
238
it('does not warn when the array contains a non-element', function() {
@@ -240,7 +240,7 @@ describe('ReactElementClone', function() {
240
241
React.cloneElement(<div />, null, [{}, {}]);
242
243
- expect(console.error.argsForCall.length).toBe(0);
243
+ expect(console.error.calls.count()).toBe(0);
244
});
245
246
it('should check declared prop types after clone', function() {
@@ -267,8 +267,8 @@ describe('ReactElementClone', function() {
267
},
268
});
269
ReactTestUtils.renderIntoDocument(React.createElement(GrandParent));
270
- expect(console.error.argsForCall.length).toBe(1);
271
- expect(console.error.argsForCall[0][0]).toBe(
270
+ expect(console.error.calls.count()).toBe(1);
271
+ expect(console.error.calls.argsFor(0)[0]).toBe(
272
'Warning: Failed prop type: ' +
273
'Invalid prop `color` of type `number` supplied to `Component`, ' +
274
'expected `string`.\n' +
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
+43
-43
@@ -44,8 +44,8 @@ describe('ReactElementValidator', function() {
44
45
Component(null, [Component(), Component()]);
46
47
- expect(console.error.argsForCall.length).toBe(1);
48
- expect(console.error.argsForCall[0][0]).toContain(
47
+ expect(console.error.calls.count()).toBe(1);
48
+ expect(console.error.calls.argsFor(0)[0]).toContain(
49
'Each child in an array or iterator should have a unique "key" prop.'
50
);
51
});
@@ -74,8 +74,8 @@ describe('ReactElementValidator', function() {
74
React.createElement(ComponentWrapper)
75
);
76
77
- expect(console.error.argsForCall.length).toBe(1);
78
- expect(console.error.argsForCall[0][0]).toContain(
77
+ expect(console.error.calls.count()).toBe(1);
78
+ expect(console.error.calls.argsFor(0)[0]).toContain(
79
'Each child in an array or iterator should have a unique "key" prop. ' +
80
'Check the render method of `InnerClass`. ' +
81
'It was passed a child from ComponentWrapper. '
@@ -98,8 +98,8 @@ describe('ReactElementValidator', function() {
98
];
99
ReactTestUtils.renderIntoDocument(<Anonymous>{divs}</Anonymous>);
100
101
- expect(console.error.argsForCall.length).toBe(1);
102
- expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe(
101
+ expect(console.error.calls.count()).toBe(1);
102
+ expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
103
'Warning: Each child in an array or iterator should have a unique ' +
104
'"key" prop. See https://fb.me/react-warning-keys for more information.\n' +
105
' in div (at **)'
@@ -115,8 +115,8 @@ describe('ReactElementValidator', function() {
115
];
116
ReactTestUtils.renderIntoDocument(<div>{divs}</div>);
117
118
- expect(console.error.argsForCall.length).toBe(1);
119
- expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe(
118
+ expect(console.error.calls.count()).toBe(1);
119
+ expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
120
'Warning: Each child in an array or iterator should have a unique ' +
121
'"key" prop. Check the top-level render call using <div>. See ' +
122
'https://fb.me/react-warning-keys for more information.\n' +
@@ -147,8 +147,8 @@ describe('ReactElementValidator', function() {
147
148
ReactTestUtils.renderIntoDocument(<GrandParent />);
149
150
- expect(console.error.argsForCall.length).toBe(1);
151
- expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe(
150
+ expect(console.error.calls.count()).toBe(1);
151
+ expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
152
'Warning: Each child in an array or iterator should have a unique ' +
153
'"key" prop. Check the render method of `Component`. See ' +
154
'https://fb.me/react-warning-keys for more information.\n' +
@@ -180,7 +180,7 @@ describe('ReactElementValidator', function() {
180
</Wrapper>
181
);
182
183
- expect(console.error.argsForCall.length).toBe(0);
183
+ expect(console.error.calls.count()).toBe(0);
184
});
185
186
it('warns for keys for iterables of elements in rest args', function() {
@@ -201,8 +201,8 @@ describe('ReactElementValidator', function() {
201
202
Component(null, iterable);
203
204
- expect(console.error.argsForCall.length).toBe(1);
205
- expect(console.error.argsForCall[0][0]).toContain(
204
+ expect(console.error.calls.count()).toBe(1);
205
+ expect(console.error.calls.argsFor(0)[0]).toContain(
206
'Each child in an array or iterator should have a unique "key" prop.'
207
);
208
});
@@ -213,7 +213,7 @@ describe('ReactElementValidator', function() {
213
214
Component(null, [Component({key: '#1'}), Component({key: '#2'})]);
215
216
- expect(console.error.argsForCall.length).toBe(0);
216
+ expect(console.error.calls.count()).toBe(0);
217
});
218
219
it('does not warns for iterable elements with keys', function() {
@@ -237,7 +237,7 @@ describe('ReactElementValidator', function() {
237
238
Component(null, iterable);
239
240
- expect(console.error.argsForCall.length).toBe(0);
240
+ expect(console.error.calls.count()).toBe(0);
241
});
242
243
it('does not warn when the element is directly in rest args', function() {
@@ -246,7 +246,7 @@ describe('ReactElementValidator', function() {
246
247
Component(null, Component(), Component());
248
249
- expect(console.error.argsForCall.length).toBe(0);
249
+ expect(console.error.calls.count()).toBe(0);
250
});
251
252
it('does not warn when the array contains a non-element', function() {
@@ -255,7 +255,7 @@ describe('ReactElementValidator', function() {
255
256
Component(null, [{}, {}]);
257
258
- expect(console.error.argsForCall.length).toBe(0);
258
+ expect(console.error.calls.count()).toBe(0);
259
});
260
261
// TODO: These warnings currently come from the composite component, but
@@ -280,7 +280,7 @@ describe('ReactElementValidator', function() {
280
},
281
});
282
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
283
- expect(console.error.argsForCall[0][0]).toBe(
283
+ expect(console.error.calls.argsFor(0)[0]).toBe(
284
'Warning: Failed prop type: ' +
285
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
286
'expected `string`.\n' +
@@ -295,29 +295,29 @@ describe('ReactElementValidator', function() {
295
React.createElement(null);
296
React.createElement(true);
297
React.createElement(123);
298
- expect(console.error.calls.length).toBe(4);
299
- expect(console.error.argsForCall[0][0]).toBe(
298
+ expect(console.error.calls.count()).toBe(4);
299
+ expect(console.error.calls.argsFor(0)[0]).toBe(
300
'Warning: React.createElement: type should not be null, undefined, ' +
301
'boolean, or number. It should be a string (for DOM elements) or a ' +
302
'ReactClass (for composite components).'
303
);
304
- expect(console.error.argsForCall[1][0]).toBe(
304
+ expect(console.error.calls.argsFor(1)[0]).toBe(
305
'Warning: React.createElement: type should not be null, undefined, ' +
306
'boolean, or number. It should be a string (for DOM elements) or a ' +
307
'ReactClass (for composite components).'
308
);
309
- expect(console.error.argsForCall[2][0]).toBe(
309
+ expect(console.error.calls.argsFor(2)[0]).toBe(
310
'Warning: React.createElement: type should not be null, undefined, ' +
311
'boolean, or number. It should be a string (for DOM elements) or a ' +
312
'ReactClass (for composite components).'
313
);
314
- expect(console.error.argsForCall[3][0]).toBe(
314
+ expect(console.error.calls.argsFor(3)[0]).toBe(
315
'Warning: React.createElement: type should not be null, undefined, ' +
316
'boolean, or number. It should be a string (for DOM elements) or a ' +
317
'ReactClass (for composite components).'
318
);
319
React.createElement('div');
320
- expect(console.error.calls.length).toBe(4);
320
+ expect(console.error.calls.count()).toBe(4);
321
});
322
323
it('includes the owner name when passing null, undefined, boolean, or number', function() {
@@ -329,13 +329,13 @@ describe('ReactElementValidator', function() {
329
});
330
expect(function() {
331
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
332
- }).toThrow(
332
+ }).toThrowError(
333
'Element type is invalid: expected a string (for built-in components) ' +
334
'or a class/function (for composite components) but got: null. Check ' +
335
'the render method of `ParentComp`.'
336
);
337
- expect(console.error.calls.length).toBe(1);
338
- expect(console.error.argsForCall[0][0]).toBe(
337
+ expect(console.error.calls.count()).toBe(1);
338
+ expect(console.error.calls.argsFor(0)[0]).toBe(
339
'Warning: React.createElement: type should not be null, undefined, ' +
340
'boolean, or number. It should be a string (for DOM elements) or a ' +
341
'ReactClass (for composite components). Check the render method of ' +
@@ -358,8 +358,8 @@ describe('ReactElementValidator', function() {
358
359
ReactTestUtils.renderIntoDocument(React.createElement(Component));
360
361
- expect(console.error.calls.length).toBe(1);
362
- expect(console.error.argsForCall[0][0]).toBe(
361
+ expect(console.error.calls.count()).toBe(1);
362
+ expect(console.error.calls.argsFor(0)[0]).toBe(
363
'Warning: Failed prop type: ' +
364
'Required prop `prop` was not specified in `Component`.\n' +
365
' in Component'
@@ -383,8 +383,8 @@ describe('ReactElementValidator', function() {
383
React.createElement(Component, {prop:null})
384
);
385
386
- expect(console.error.calls.length).toBe(1);
387
- expect(console.error.argsForCall[0][0]).toBe(
386
+ expect(console.error.calls.count()).toBe(1);
387
+ expect(console.error.calls.argsFor(0)[0]).toBe(
388
'Warning: Failed prop type: ' +
389
'Required prop `prop` was not specified in `Component`.\n' +
390
' in Component'
@@ -410,14 +410,14 @@ describe('ReactElementValidator', function() {
410
React.createElement(Component, {prop: 42})
411
);
412
413
- expect(console.error.calls.length).toBe(2);
414
- expect(console.error.argsForCall[0][0]).toBe(
413
+ expect(console.error.calls.count()).toBe(2);
414
+ expect(console.error.calls.argsFor(0)[0]).toBe(
415
'Warning: Failed prop type: ' +
416
'Required prop `prop` was not specified in `Component`.\n' +
417
' in Component'
418
);
419
420
- expect(console.error.argsForCall[1][0]).toBe(
420
+ expect(console.error.calls.argsFor(1)[0]).toBe(
421
'Warning: Failed prop type: ' +
422
'Invalid prop `prop` of type `number` supplied to ' +
423
'`Component`, expected `string`.\n' +
@@ -429,7 +429,7 @@ describe('ReactElementValidator', function() {
429
);
430
431
// Should not error for strings
432
- expect(console.error.calls.length).toBe(2);
432
+ expect(console.error.calls.count()).toBe(2);
433
});
434
435
it('should warn if a PropType creator is used as a PropType', function() {
@@ -448,8 +448,8 @@ describe('ReactElementValidator', function() {
448
React.createElement(Component, {myProp: {value: 'hi'}})
449
);
450
451
- expect(console.error.calls.length).toBe(1);
452
- expect(console.error.argsForCall[0][0]).toBe(
451
+ expect(console.error.calls.count()).toBe(1);
452
+ expect(console.error.calls.argsFor(0)[0]).toBe(
453
'Warning: Component: type specification of prop `myProp` is invalid; ' +
454
'the type checker function must return `null` or an `Error` but ' +
455
'returned a function. You may have forgotten to pass an argument to ' +
@@ -467,14 +467,14 @@ describe('ReactElementValidator', function() {
467
});
468
var TestFactory = React.createFactory(TestComponent);
469
expect(TestFactory.type).toBe(TestComponent);
470
- expect(console.error.argsForCall.length).toBe(1);
471
- expect(console.error.argsForCall[0][0]).toBe(
470
+ expect(console.error.calls.count()).toBe(1);
471
+ expect(console.error.calls.argsFor(0)[0]).toBe(
472
'Warning: Factory.type is deprecated. Access the class directly before ' +
473
'passing it to createFactory.'
474
);
475
// Warn once, not again
476
expect(TestFactory.type).toBe(TestComponent);
477
- expect(console.error.argsForCall.length).toBe(1);
477
+ expect(console.error.calls.count()).toBe(1);
478
});
479
480
it('does not warn when using DOM node as children', function() {
@@ -491,7 +491,7 @@ describe('ReactElementValidator', function() {
491
var node = document.createElement('div');
492
// This shouldn't cause a stack overflow or any other problems (#3883)
493
ReactTestUtils.renderIntoDocument(<DOMContainer>{node}</DOMContainer>);
494
- expect(console.error.argsForCall.length).toBe(0);
494
+ expect(console.error.calls.count()).toBe(0);
495
});
496
497
it('should not enumerate enumerable numbers (#4776)', function() {
@@ -534,8 +534,8 @@ describe('ReactElementValidator', function() {
534
spyOn(console, 'error');
535
var Foo = undefined;
536
void <Foo>{[<div />]}</Foo>;
537
- expect(console.error.argsForCall.length).toBe(1);
538
- expect(console.error.argsForCall[0][0]).toBe(
537
+ expect(console.error.calls.count()).toBe(1);
538
+ expect(console.error.calls.argsFor(0)[0]).toBe(
539
'Warning: React.createElement: type should not be null, undefined, ' +
540
'boolean, or number. It should be a string (for DOM elements) or a ' +
541
'ReactClass (for composite components).'
src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
+12
-14
@@ -271,7 +271,7 @@ describe('ReactPropTypes', function() {
271
var instance = <Component label={<div />} />;
272
instance = ReactTestUtils.renderIntoDocument(instance);
273
274
- expect(console.error.argsForCall.length).toBe(0);
274
+ expect(console.error.calls.count()).toBe(0);
275
});
276
277
it('should warn when passing no label and isRequired is set', () => {
@@ -280,7 +280,7 @@ describe('ReactPropTypes', function() {
280
var instance = <Component />;
281
instance = ReactTestUtils.renderIntoDocument(instance);
282
283
- expect(console.error.argsForCall.length).toBe(1);
283
+ expect(console.error.calls.count()).toBe(1);
284
});
285
286
it('should be implicitly optional and not warn without values', function() {
@@ -421,7 +421,7 @@ describe('ReactPropTypes', function() {
421
k4: null,
422
k5: undefined,
423
}));
424
- expect(console.error.calls).toEqual([]);
424
+ expect(console.error.calls.count()).toBe(0);
425
});
426
427
it('should not warn for iterables', function() {
@@ -849,8 +849,8 @@ describe('ReactPropTypes', function() {
849
var instance = <Component num={5} />;
850
instance = ReactTestUtils.renderIntoDocument(instance);
851
852
- expect(spy.argsForCall.length).toBe(1);
853
- expect(spy.argsForCall[0][1]).toBe('num');
852
+ expect(spy.calls.count()).toBe(1);
853
+ expect(spy.calls.argsFor(0)[1]).toBe('num');
854
});
855
856
it('should have been called even if the prop is not present', function() {
@@ -866,14 +866,13 @@ describe('ReactPropTypes', function() {
866
var instance = <Component bla={5} />;
867
instance = ReactTestUtils.renderIntoDocument(instance);
868
869
- expect(spy.argsForCall.length).toBe(1);
870
- expect(spy.argsForCall[0][1]).toBe('num');
869
+ expect(spy.calls.count()).toBe(1);
870
+ expect(spy.calls.argsFor(0)[1]).toBe('num');
871
});
872
873
it('should have received the validator\'s return value', function() {
874
spyOn(console, 'error');
875
-
876
- var spy = jasmine.createSpy().andCallFake(
875
+ var spy = jasmine.createSpy().and.callFake(
876
function(props, propName, componentName) {
877
if (props[propName] !== 5) {
878
return new Error('num must be 5!');
@@ -890,9 +889,9 @@ describe('ReactPropTypes', function() {
889
890
var instance = <Component num={6} />;
891
instance = ReactTestUtils.renderIntoDocument(instance);
893
- expect(console.error.argsForCall.length).toBe(1);
892
+ expect(console.error.calls.count()).toBe(1);
893
expect(
895
- console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)')
894
+ console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)')
895
).toBe(
896
'Warning: Failed prop type: num must be 5!\n' +
897
' in Component (at **)'
@@ -902,8 +901,7 @@ describe('ReactPropTypes', function() {
901
it('should not warn if the validator returned null',
902
function() {
903
spyOn(console, 'error');
905
-
906
- var spy = jasmine.createSpy().andCallFake(
904
+ var spy = jasmine.createSpy().and.callFake(
905
function(props, propName, componentName) {
906
return null;
907
}
@@ -918,7 +916,7 @@ describe('ReactPropTypes', function() {
916
917
var instance = <Component num={5} />;
918
instance = ReactTestUtils.renderIntoDocument(instance);
921
- expect(console.error.argsForCall.length).toBe(0);
919
+ expect(console.error.calls.count()).toBe(0);
920
}
921
);
922
});
src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee
+15
-15
@@ -51,8 +51,8 @@ describe 'ReactCoffeeScriptClass', ->
51
expect(->
52
ReactDOM.render React.createElement(Foo), container
53
).toThrow()
54
- expect(console.error.calls.length).toBe(1)
55
- expect(console.error.argsForCall[0][0]).toContain('No `render` method found on the returned component instance')
54
+ expect(console.error.calls.count()).toBe(1)
55
+ expect(console.error.calls.argsFor(0)[0]).toContain('No `render` method found on the returned component instance')
56
57
it 'renders a simple stateless component with prop', ->
58
class Foo extends React.Component
@@ -153,7 +153,7 @@ describe 'ReactCoffeeScriptClass', ->
153
154
expect(->
155
test React.createElement(Foo), 'span', ''
156
- ).toThrow(
156
+ ).toThrowError(
157
'Foo.state: must be set to an object or null'
158
)
159
@@ -292,17 +292,17 @@ describe 'ReactCoffeeScriptClass', ->
292
test React.createElement(Foo), 'SPAN', 'foo'
293
expect(getInitialStateWasCalled).toBe false
294
expect(getDefaultPropsWasCalled).toBe false
295
- expect(console.error.calls.length).toBe 4
296
- expect(console.error.argsForCall[0][0]).toContain(
295
+ expect(console.error.calls.count()).toBe 4
296
+ expect(console.error.calls.argsFor(0)[0]).toContain(
297
'getInitialState was defined on Foo, a plain JavaScript class.'
298
)
299
- expect(console.error.argsForCall[1][0]).toContain(
299
+ expect(console.error.calls.argsFor(1)[0]).toContain(
300
'getDefaultProps was defined on Foo, a plain JavaScript class.'
301
)
302
- expect(console.error.argsForCall[2][0]).toContain(
302
+ expect(console.error.calls.argsFor(2)[0]).toContain(
303
'propTypes was defined as an instance property on Foo.'
304
)
305
- expect(console.error.argsForCall[3][0]).toContain(
305
+ expect(console.error.calls.argsFor(3)[0]).toContain(
306
'contextTypes was defined as an instance property on Foo.'
307
)
308
@@ -317,8 +317,8 @@ describe 'ReactCoffeeScriptClass', ->
317
className: 'foo'
318
319
test React.createElement(NamedComponent), 'SPAN', 'foo'
320
- expect(console.error.calls.length).toBe 1
321
- expect(console.error.argsForCall[0][0]).toBe(
320
+ expect(console.error.calls.count()).toBe 1
321
+ expect(console.error.calls.argsFor(0)[0]).toBe(
322
'Warning: NamedComponent has a method called componentShouldUpdate().
323
Did you mean shouldComponentUpdate()? The name is phrased as a
324
question because the function is expected to return a value.'
@@ -335,8 +335,8 @@ describe 'ReactCoffeeScriptClass', ->
335
className: 'foo'
336
337
test React.createElement(NamedComponent), 'SPAN', 'foo'
338
- expect(console.error.calls.length).toBe 1
339
- expect(console.error.argsForCall[0][0]).toBe(
338
+ expect(console.error.calls.count()).toBe 1
339
+ expect(console.error.calls.argsFor(0)[0]).toBe(
340
'Warning: NamedComponent has a method called componentWillRecieveProps().
341
Did you mean componentWillReceiveProps()?'
342
)
@@ -349,11 +349,11 @@ describe 'ReactCoffeeScriptClass', ->
349
expect(-> instance.isMounted()).toThrow()
350
expect(-> instance.setProps name: 'bar').toThrow()
351
expect(-> instance.replaceProps name: 'bar').toThrow()
352
- expect(console.error.calls.length).toBe 2
353
- expect(console.error.argsForCall[0][0]).toContain(
352
+ expect(console.error.calls.count()).toBe 2
353
+ expect(console.error.calls.argsFor(0)[0]).toContain(
354
'replaceState(...) is deprecated in plain JavaScript React classes'
355
)
356
- expect(console.error.argsForCall[1][0]).toContain(
356
+ expect(console.error.calls.argsFor(1)[0]).toContain(
357
'isMounted(...) is deprecated in plain JavaScript React classes'
358
)
359
src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
+15
-15
@@ -61,8 +61,8 @@ describe('ReactES6Class', function() {
61
class Foo extends React.Component { }
62
expect(() => ReactDOM.render(<Foo />, container)).toThrow();
63
64
- expect(console.error.calls.length).toBe(1);
65
- expect(console.error.argsForCall[0][0]).toBe(
64
+ expect(console.error.calls.count()).toBe(1);
65
+ expect(console.error.calls.argsFor(0)[0]).toBe(
66
'Warning: Foo(...): No `render` method found on the returned component ' +
67
'instance: you may have forgotten to define `render`.'
68
);
@@ -173,7 +173,7 @@ describe('ReactES6Class', function() {
173
return <span />;
174
}
175
}
176
- expect(() => test(<Foo />, 'span', '')).toThrow(
176
+ expect(() => test(<Foo />, 'span', '')).toThrowError(
177
'Foo.state: must be set to an object or null'
178
);
179
});
@@ -339,17 +339,17 @@ describe('ReactES6Class', function() {
339
test(<Foo />, 'SPAN', 'foo');
340
expect(getInitialStateWasCalled).toBe(false);
341
expect(getDefaultPropsWasCalled).toBe(false);
342
- expect(console.error.calls.length).toBe(4);
343
- expect(console.error.argsForCall[0][0]).toContain(
342
+ expect(console.error.calls.count()).toBe(4);
343
+ expect(console.error.calls.argsFor(0)[0]).toContain(
344
'getInitialState was defined on Foo, a plain JavaScript class.'
345
);
346
- expect(console.error.argsForCall[1][0]).toContain(
346
+ expect(console.error.calls.argsFor(1)[0]).toContain(
347
'getDefaultProps was defined on Foo, a plain JavaScript class.'
348
);
349
- expect(console.error.argsForCall[2][0]).toContain(
349
+ expect(console.error.calls.argsFor(2)[0]).toContain(
350
'propTypes was defined as an instance property on Foo.'
351
);
352
- expect(console.error.argsForCall[3][0]).toContain(
352
+ expect(console.error.calls.argsFor(3)[0]).toContain(
353
'contextTypes was defined as an instance property on Foo.'
354
);
355
});
@@ -367,8 +367,8 @@ describe('ReactES6Class', function() {
367
}
368
test(<NamedComponent />, 'SPAN', 'foo');
369
370
- expect(console.error.calls.length).toBe(1);
371
- expect(console.error.argsForCall[0][0]).toBe(
370
+ expect(console.error.calls.count()).toBe(1);
371
+ expect(console.error.calls.argsFor(0)[0]).toBe(
372
'Warning: ' +
373
'NamedComponent has a method called componentShouldUpdate(). Did you ' +
374
'mean shouldComponentUpdate()? The name is phrased as a question ' +
@@ -389,8 +389,8 @@ describe('ReactES6Class', function() {
389
}
390
test(<NamedComponent />, 'SPAN', 'foo');
391
392
- expect(console.error.calls.length).toBe(1);
393
- expect(console.error.argsForCall[0][0]).toBe(
392
+ expect(console.error.calls.count()).toBe(1);
393
+ expect(console.error.calls.argsFor(0)[0]).toBe(
394
'Warning: ' +
395
'NamedComponent has a method called componentWillRecieveProps(). Did ' +
396
'you mean componentWillReceiveProps()?'
@@ -404,11 +404,11 @@ describe('ReactES6Class', function() {
404
expect(() => instance.isMounted()).toThrow();
405
expect(() => instance.setProps({name: 'bar'})).toThrow();
406
expect(() => instance.replaceProps({name: 'bar'})).toThrow();
407
- expect(console.error.calls.length).toBe(2);
408
- expect(console.error.argsForCall[0][0]).toContain(
407
+ expect(console.error.calls.count()).toBe(2);
408
+ expect(console.error.calls.argsFor(0)[0]).toContain(
409
'replaceState(...) is deprecated in plain JavaScript React classes'
410
);
411
- expect(console.error.argsForCall[1][0]).toContain(
411
+ expect(console.error.calls.argsFor(1)[0]).toContain(
412
'isMounted(...) is deprecated in plain JavaScript React classes'
413
);
414
});
src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts
+17
-17
@@ -319,8 +319,8 @@ describe('ReactTypeScriptClass', function() {
319
320
expect(() => ReactDOM.render(React.createElement(Empty), container)).toThrow();
321
322
- expect((<any>console.error).argsForCall.length).toBe(1);
323
- expect((<any>console.error).argsForCall[0][0]).toBe(
322
+ expect((<any>console.error).calls.count()).toBe(1);
323
+ expect((<any>console.error).calls.argsFor(0)[0]).toBe(
324
'Warning: Empty(...): No `render` method found on the returned ' +
325
'component instance: you may have forgotten to define `render`.'
326
);
@@ -361,15 +361,15 @@ describe('ReactTypeScriptClass', function() {
361
362
it('should throw with non-object in the initial state property', function() {
363
expect(() => test(React.createElement(ArrayState), 'span', ''))
364
- .toThrow(
364
+ .toThrowError(
365
'ArrayState.state: must be set to an object or null'
366
);
367
expect(() => test(React.createElement(StringState), 'span', ''))
368
- .toThrow(
368
+ .toThrowError(
369
'StringState.state: must be set to an object or null'
370
);
371
expect(() => test(React.createElement(NumberState), 'span', ''))
372
- .toThrow(
372
+ .toThrowError(
373
'NumberState.state: must be set to an object or null'
374
);
375
});
@@ -437,19 +437,19 @@ describe('ReactTypeScriptClass', function() {
437
test(React.createElement(ClassicProperties), 'SPAN', 'foo');
438
expect(getInitialStateWasCalled).toBe(false);
439
expect(getDefaultPropsWasCalled).toBe(false);
440
- expect((<any>console.error).argsForCall.length).toBe(4);
441
- expect((<any>console.error).argsForCall[0][0]).toContain(
440
+ expect((<any>console.error).calls.count()).toBe(4);
441
+ expect((<any>console.error).calls.argsFor(0)[0]).toContain(
442
'getInitialState was defined on ClassicProperties, ' +
443
'a plain JavaScript class.'
444
);
445
- expect((<any>console.error).argsForCall[1][0]).toContain(
445
+ expect((<any>console.error).calls.argsFor(1)[0]).toContain(
446
'getDefaultProps was defined on ClassicProperties, ' +
447
'a plain JavaScript class.'
448
);
449
- expect((<any>console.error).argsForCall[2][0]).toContain(
449
+ expect((<any>console.error).calls.argsFor(2)[0]).toContain(
450
'propTypes was defined as an instance property on ClassicProperties.'
451
);
452
- expect((<any>console.error).argsForCall[3][0]).toContain(
452
+ expect((<any>console.error).calls.argsFor(3)[0]).toContain(
453
'contextTypes was defined as an instance property on ClassicProperties.'
454
);
455
});
@@ -459,8 +459,8 @@ describe('ReactTypeScriptClass', function() {
459
460
test(React.createElement(MisspelledComponent1), 'SPAN', 'foo');
461
462
- expect((<any>console.error).argsForCall.length).toBe(1);
463
- expect((<any>console.error).argsForCall[0][0]).toBe(
462
+ expect((<any>console.error).calls.count()).toBe(1);
463
+ expect((<any>console.error).calls.argsFor(0)[0]).toBe(
464
'Warning: ' +
465
'MisspelledComponent1 has a method called componentShouldUpdate(). Did ' +
466
'you mean shouldComponentUpdate()? The name is phrased as a question ' +
@@ -473,8 +473,8 @@ describe('ReactTypeScriptClass', function() {
473
474
test(React.createElement(MisspelledComponent2), 'SPAN', 'foo');
475
476
- expect((<any>console.error).argsForCall.length).toBe(1);
477
- expect((<any>console.error).argsForCall[0][0]).toBe(
476
+ expect((<any>console.error).calls.count()).toBe(1);
477
+ expect((<any>console.error).calls.argsFor(0)[0]).toBe(
478
'Warning: ' +
479
'MisspelledComponent2 has a method called componentWillRecieveProps(). ' +
480
'Did you mean componentWillReceiveProps()?'
@@ -491,11 +491,11 @@ describe('ReactTypeScriptClass', function() {
491
expect(() => instance.isMounted()).toThrow();
492
expect(() => instance.setProps({ name: 'bar' })).toThrow();
493
expect(() => instance.replaceProps({ name: 'bar' })).toThrow();
494
- expect((<any>console.error).argsForCall.length).toBe(2);
495
- expect((<any>console.error).argsForCall[0][0]).toContain(
494
+ expect((<any>console.error).calls.count()).toBe(2);
495
+ expect((<any>console.error).calls.argsFor(0)[0]).toContain(
496
'replaceState(...) is deprecated in plain JavaScript React classes'
497
);
498
- expect((<any>console.error).argsForCall[1][0]).toContain(
498
+ expect((<any>console.error).calls.argsFor(1)[0]).toContain(
499
'isMounted(...) is deprecated in plain JavaScript React classes'
500
);
501
});
src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
+5
-5
@@ -100,21 +100,21 @@ describe('ReactJSXElement', function() {
100
var a = 1;
101
var element = <Component children="text">{a}</Component>;
102
expect(element.props.children).toBe(a);
103
- expect(console.error.argsForCall.length).toBe(0);
103
+ expect(console.error.calls.count()).toBe(0);
104
});
105
106
it('does not override children if no JSX children are provided', function() {
107
spyOn(console, 'error');
108
var element = <Component children="text" />;
109
expect(element.props.children).toBe('text');
110
- expect(console.error.argsForCall.length).toBe(0);
110
+ expect(console.error.calls.count()).toBe(0);
111
});
112
113
it('overrides children if null is provided as a JSX child', function() {
114
spyOn(console, 'error');
115
var element = <Component children="text">{null}</Component>;
116
expect(element.props.children).toBe(null);
117
- expect(console.error.argsForCall.length).toBe(0);
117
+ expect(console.error.calls.count()).toBe(0);
118
});
119
120
it('overrides children if undefined is provided as an argument', function() {
@@ -136,7 +136,7 @@ describe('ReactJSXElement', function() {
136
var c = 3;
137
var element = <Component>{a}{b}{c}</Component>;
138
expect(element.props.children).toEqual([1, 2, 3]);
139
- expect(console.error.argsForCall.length).toBe(0);
139
+ expect(console.error.calls.count()).toBe(0);
140
});
141
142
it('allows static methods to be called using the type property', function() {
@@ -153,7 +153,7 @@ describe('ReactJSXElement', function() {
153
154
var element = <StaticMethodComponent />;
155
expect(element.type.someStaticMethod()).toBe('someReturnValue');
156
- expect(console.error.argsForCall.length).toBe(0);
156
+ expect(console.error.calls.count()).toBe(0);
157
});
158
159
it('identifies valid elements', function() {
src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
+32
-32
@@ -47,8 +47,8 @@ describe('ReactJSXElementValidator', function() {
47
48
void <Component>{[<Component />, <Component />]}</Component>;
49
50
- expect(console.error.argsForCall.length).toBe(1);
51
- expect(console.error.argsForCall[0][0]).toContain(
50
+ expect(console.error.calls.count()).toBe(1);
51
+ expect(console.error.calls.argsFor(0)[0]).toContain(
52
'Each child in an array or iterator should have a unique "key" prop.'
53
);
54
});
@@ -74,8 +74,8 @@ describe('ReactJSXElementValidator', function() {
74
75
ReactTestUtils.renderIntoDocument(<ComponentWrapper />);
76
77
- expect(console.error.argsForCall.length).toBe(1);
78
- expect(console.error.argsForCall[0][0]).toContain(
77
+ expect(console.error.calls.count()).toBe(1);
78
+ expect(console.error.calls.argsFor(0)[0]).toContain(
79
'Each child in an array or iterator should have a unique "key" prop. ' +
80
'Check the render method of `InnerComponent`. ' +
81
'It was passed a child from ComponentWrapper. '
@@ -99,8 +99,8 @@ describe('ReactJSXElementValidator', function() {
99
100
void <Component>{iterable}</Component>;
101
102
- expect(console.error.argsForCall.length).toBe(1);
103
- expect(console.error.argsForCall[0][0]).toContain(
102
+ expect(console.error.calls.count()).toBe(1);
103
+ expect(console.error.calls.argsFor(0)[0]).toContain(
104
'Each child in an array or iterator should have a unique "key" prop.'
105
);
106
});
@@ -110,7 +110,7 @@ describe('ReactJSXElementValidator', function() {
110
111
void <Component>{[<Component key="#1" />, <Component key="#2" />]}</Component>;
112
113
- expect(console.error.argsForCall.length).toBe(0);
113
+ expect(console.error.calls.count()).toBe(0);
114
});
115
116
it('does not warns for iterable elements with keys', function() {
@@ -133,7 +133,7 @@ describe('ReactJSXElementValidator', function() {
133
134
void <Component>{iterable}</Component>;
135
136
- expect(console.error.argsForCall.length).toBe(0);
136
+ expect(console.error.calls.count()).toBe(0);
137
});
138
139
it('does not warn for numeric keys in entry iterable as a child', function() {
@@ -154,7 +154,7 @@ describe('ReactJSXElementValidator', function() {
154
155
void <Component>{iterable}</Component>;
156
157
- expect(console.error.argsForCall.length).toBe(0);
157
+ expect(console.error.calls.count()).toBe(0);
158
});
159
160
it('does not warn when the element is directly as children', function() {
@@ -162,7 +162,7 @@ describe('ReactJSXElementValidator', function() {
162
163
void <Component><Component /><Component /></Component>;
164
165
- expect(console.error.argsForCall.length).toBe(0);
165
+ expect(console.error.calls.count()).toBe(0);
166
});
167
168
it('does not warn when the child array contains non-elements', function() {
@@ -170,7 +170,7 @@ describe('ReactJSXElementValidator', function() {
170
171
void <Component>{[{}, {}]}</Component>;
172
173
- expect(console.error.argsForCall.length).toBe(0);
173
+ expect(console.error.calls.count()).toBe(0);
174
});
175
176
// TODO: These warnings currently come from the composite component, but
@@ -196,7 +196,7 @@ describe('ReactJSXElementValidator', function() {
196
}
197
ReactTestUtils.renderIntoDocument(<ParentComp />);
198
expect(
199
- console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)')
199
+ console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)')
200
).toBe(
201
'Warning: Failed prop type: ' +
202
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
@@ -217,25 +217,25 @@ describe('ReactJSXElementValidator', function() {
217
void <Null />;
218
void <True />;
219
void <Num />;
220
- expect(console.error.calls.length).toBe(4);
221
- expect(console.error.argsForCall[0][0]).toContain(
220
+ expect(console.error.calls.count()).toBe(4);
221
+ expect(console.error.calls.argsFor(0)[0]).toContain(
222
'type should not be null, undefined, boolean, or number. It should be ' +
223
'a string (for DOM elements) or a ReactClass (for composite components).'
224
);
225
- expect(console.error.argsForCall[1][0]).toContain(
225
+ expect(console.error.calls.argsFor(1)[0]).toContain(
226
'type should not be null, undefined, boolean, or number. It should be ' +
227
'a string (for DOM elements) or a ReactClass (for composite components).'
228
);
229
- expect(console.error.argsForCall[2][0]).toContain(
229
+ expect(console.error.calls.argsFor(2)[0]).toContain(
230
'type should not be null, undefined, boolean, or number. It should be ' +
231
'a string (for DOM elements) or a ReactClass (for composite components).'
232
);
233
- expect(console.error.argsForCall[3][0]).toContain(
233
+ expect(console.error.calls.argsFor(3)[0]).toContain(
234
'type should not be null, undefined, boolean, or number. It should be ' +
235
'a string (for DOM elements) or a ReactClass (for composite components).'
236
);
237
void <Div />;
238
- expect(console.error.calls.length).toBe(4);
238
+ expect(console.error.calls.count()).toBe(4);
239
});
240
241
it('should check default prop values', function() {
@@ -245,9 +245,9 @@ describe('ReactJSXElementValidator', function() {
245
246
ReactTestUtils.renderIntoDocument(<RequiredPropComponent />);
247
248
- expect(console.error.calls.length).toBe(1);
248
+ expect(console.error.calls.count()).toBe(1);
249
expect(
250
- console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)')
250
+ console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)')
251
).toBe(
252
'Warning: Failed prop type: ' +
253
'Required prop `prop` was not specified in `RequiredPropComponent`.\n' +
@@ -260,9 +260,9 @@ describe('ReactJSXElementValidator', function() {
260
261
ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop={null} />);
262
263
- expect(console.error.calls.length).toBe(1);
263
+ expect(console.error.calls.count()).toBe(1);
264
expect(
265
- console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)')
265
+ console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)')
266
).toBe(
267
'Warning: Failed prop type: ' +
268
'Required prop `prop` was not specified in `RequiredPropComponent`.\n' +
@@ -276,9 +276,9 @@ describe('ReactJSXElementValidator', function() {
276
ReactTestUtils.renderIntoDocument(<RequiredPropComponent />);
277
ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop={42} />);
278
279
- expect(console.error.calls.length).toBe(2);
279
+ expect(console.error.calls.count()).toBe(2);
280
expect(
281
- console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)')
281
+ console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)')
282
).toBe(
283
'Warning: Failed prop type: ' +
284
'Required prop `prop` was not specified in `RequiredPropComponent`.\n' +
@@ -286,7 +286,7 @@ describe('ReactJSXElementValidator', function() {
286
);
287
288
expect(
289
- console.error.argsForCall[1][0].replace(/\(at .+?:\d+\)/g, '(at **)')
289
+ console.error.calls.argsFor(1)[0].replace(/\(at .+?:\d+\)/g, '(at **)')
290
).toBe(
291
'Warning: Failed prop type: ' +
292
'Invalid prop `prop` of type `number` supplied to ' +
@@ -297,7 +297,7 @@ describe('ReactJSXElementValidator', function() {
297
ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop="string" />);
298
299
// Should not error for strings
300
- expect(console.error.calls.length).toBe(2);
300
+ expect(console.error.calls.count()).toBe(2);
301
});
302
303
it('should warn on invalid prop types', function() {
@@ -315,8 +315,8 @@ describe('ReactJSXElementValidator', function() {
315
prop: null,
316
};
317
ReactTestUtils.renderIntoDocument(<NullPropTypeComponent />);
318
- expect(console.error.calls.length).toBe(1);
319
- expect(console.error.argsForCall[0][0]).toContain(
318
+ expect(console.error.calls.count()).toBe(1);
319
+ expect(console.error.calls.argsFor(0)[0]).toContain(
320
'NullPropTypeComponent: prop type `prop` is invalid; it must be a ' +
321
'function, usually from React.PropTypes.'
322
);
@@ -333,8 +333,8 @@ describe('ReactJSXElementValidator', function() {
333
prop: null,
334
};
335
ReactTestUtils.renderIntoDocument(<NullContextTypeComponent />);
336
- expect(console.error.calls.length).toBe(1);
337
- expect(console.error.argsForCall[0][0]).toContain(
336
+ expect(console.error.calls.count()).toBe(1);
337
+ expect(console.error.calls.argsFor(0)[0]).toContain(
338
'NullContextTypeComponent: context type `prop` is invalid; it must ' +
339
'be a function, usually from React.PropTypes.'
340
);
@@ -351,8 +351,8 @@ describe('ReactJSXElementValidator', function() {
351
prop: 'foo',
352
});
353
ReactTestUtils.renderIntoDocument(<GetDefaultPropsComponent />);
354
- expect(console.error.calls.length).toBe(1);
355
- expect(console.error.argsForCall[0][0]).toContain(
354
+ expect(console.error.calls.count()).toBe(1);
355
+ expect(console.error.calls.argsFor(0)[0]).toContain(
356
'getDefaultProps is only used on classic React.createClass definitions.' +
357
' Use a static property named `defaultProps` instead.'
358
);
src/renderers/dom/__tests__/ReactDOMProduction-test.js
+2
-2
@@ -37,7 +37,7 @@ describe('ReactDOMProduction', function() {
37
38
spyOn(console, 'error');
39
warning(false, 'Do cows go moo?');
40
- expect(console.error.argsForCall.length).toBe(0);
40
+ expect(console.error.calls.count()).toBe(0);
41
});
42
43
it('should use prod React', function() {
@@ -46,7 +46,7 @@ describe('ReactDOMProduction', function() {
46
// no key warning
47
void <div>{[<span />]}</div>;
48
49
- expect(console.error.argsForCall.length).toBe(0);
49
+ expect(console.error.calls.count()).toBe(0);
50
});
51
52
it('should handle a simple flow', function() {
src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js
+5
-5
@@ -271,7 +271,7 @@ describe('ReactBrowserEventEmitter', function() {
271
expect(idCallOrder[0]).toBe(getInternal(CHILD));
272
expect(idCallOrder[1]).toBe(getInternal(PARENT));
273
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
274
- expect(console.error.calls.length).toEqual(0);
274
+ expect(console.error.calls.count()).toEqual(0);
275
});
276
277
/**
@@ -388,7 +388,7 @@ describe('ReactBrowserEventEmitter', function() {
388
spyOn(EventListener, 'listen');
389
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
390
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
391
- expect(EventListener.listen.calls.length).toBe(1);
391
+ expect(EventListener.listen.calls.count()).toBe(1);
392
});
393
394
it('should work with event plugins without dependencies', function() {
@@ -396,7 +396,7 @@ describe('ReactBrowserEventEmitter', function() {
396
397
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
398
399
- expect(EventListener.listen.argsForCall[0][1]).toBe('click');
399
+ expect(EventListener.listen.calls.argsFor(0)[1]).toBe('click');
400
});
401
402
it('should work with event plugins with dependencies', function() {
@@ -406,8 +406,8 @@ describe('ReactBrowserEventEmitter', function() {
406
ReactBrowserEventEmitter.listenTo(ON_CHANGE_KEY, document);
407
408
var setEventListeners = [];
409
- var listenCalls = EventListener.listen.argsForCall;
410
- var captureCalls = EventListener.capture.argsForCall;
409
+ var listenCalls = EventListener.listen.calls.allArgs();
410
+ var captureCalls = EventListener.capture.calls.allArgs();
411
for (var i = 0; i < listenCalls.length; i++) {
412
setEventListeners.push(listenCalls[i][1]);
413
}
src/renderers/dom/client/__tests__/ReactDOM-test.js
+1
-1
@@ -115,7 +115,7 @@ describe('ReactDOM', function() {
115
spyOn(console, 'error');
116
var element = React.DOM.div();
117
expect(element.type).toBe('div');
118
- expect(console.error.argsForCall.length).toBe(0);
118
+ expect(console.error.calls.count()).toBe(0);
119
});
120
121
it('throws in render() if the mount callback is not a function', function() {
src/renderers/dom/client/__tests__/ReactMount-test.js
+16
-16
@@ -44,7 +44,7 @@ describe('ReactMount', function() {
44
var nodeArray = document.getElementsByTagName('div');
45
expect(function() {
46
ReactDOM.unmountComponentAtNode(nodeArray);
47
- }).toThrow(
47
+ }).toThrowError(
48
'unmountComponentAtNode(...): Target container is not a DOM element.'
49
);
50
});
@@ -53,7 +53,7 @@ describe('ReactMount', function() {
53
it('throws when given a string', function() {
54
expect(function() {
55
ReactTestUtils.renderIntoDocument('div');
56
- }).toThrow(
56
+ }).toThrowError(
57
'ReactDOM.render(): Invalid component element. Instead of passing a ' +
58
'string like \'div\', pass React.createElement(\'div\') or <div />.'
59
);
@@ -67,7 +67,7 @@ describe('ReactMount', function() {
67
});
68
expect(function() {
69
ReactTestUtils.renderIntoDocument(Component);
70
- }).toThrow(
70
+ }).toThrowError(
71
'ReactDOM.render(): Invalid component element. Instead of passing a ' +
72
'class like Foo, pass React.createElement(Foo) or <Foo />.'
73
);
@@ -133,12 +133,12 @@ describe('ReactMount', function() {
133
134
spyOn(console, 'error');
135
ReactMount.render(<div />, container);
136
- expect(console.error.calls.length).toBe(1);
136
+ expect(console.error.calls.count()).toBe(1);
137
138
container.innerHTML = ' ' + ReactDOMServer.renderToString(<div />);
139
140
ReactMount.render(<div />, container);
141
- expect(console.error.calls.length).toBe(2);
141
+ expect(console.error.calls.count()).toBe(2);
142
});
143
144
it('should not warn if mounting into non-empty node', function() {
@@ -147,7 +147,7 @@ describe('ReactMount', function() {
147
148
spyOn(console, 'error');
149
ReactMount.render(<div />, container);
150
- expect(console.error.calls.length).toBe(0);
150
+ expect(console.error.calls.count()).toBe(0);
151
});
152
153
it('should warn when mounting into document.body', function() {
@@ -157,8 +157,8 @@ describe('ReactMount', function() {
157
158
ReactMount.render(<div />, iFrame.contentDocument.body);
159
160
- expect(console.error.calls.length).toBe(1);
161
- expect(console.error.argsForCall[0][0]).toContain(
160
+ expect(console.error.calls.count()).toBe(1);
161
+ expect(console.error.calls.argsFor(0)[0]).toContain(
162
'Rendering components directly into document.body is discouraged'
163
);
164
});
@@ -174,8 +174,8 @@ describe('ReactMount', function() {
174
<div>This markup contains an nbsp entity: client text</div>,
175
div
176
);
177
- expect(console.error.calls.length).toBe(1);
178
- expect(console.error.argsForCall[0][0]).toContain(
177
+ expect(console.error.calls.count()).toBe(1);
178
+ expect(console.error.calls.argsFor(0)[0]).toContain(
179
' (client) nbsp entity: client text</div>\n' +
180
' (server) nbsp entity: server text</div>'
181
);
@@ -217,8 +217,8 @@ describe('ReactMount', function() {
217
spyOn(console, 'error');
218
var rootNode = container.firstChild;
219
ReactDOM.render(<span />, rootNode);
220
- expect(console.error.calls.length).toBe(1);
221
- expect(console.error.argsForCall[0][0]).toBe(
220
+ expect(console.error.calls.count()).toBe(1);
221
+ expect(console.error.calls.argsFor(0)[0]).toBe(
222
'Warning: render(...): Replacing React-rendered children with a new ' +
223
'root component. If you intended to update the children of this node, ' +
224
'you should instead have the existing children update their state and ' +
@@ -300,10 +300,10 @@ describe('ReactMount', function() {
300
301
ReactTestUtils.renderIntoDocument(<Foo />);
302
303
- expect(console.time.argsForCall.length).toBe(1);
304
- expect(console.time.argsForCall[0][0]).toBe('React mount: Foo');
305
- expect(console.timeEnd.argsForCall.length).toBe(1);
306
- expect(console.timeEnd.argsForCall[0][0]).toBe('React mount: Foo');
303
+ expect(console.time.calls.count()).toBe(1);
304
+ expect(console.time.calls.argsFor(0)[0]).toBe('React mount: Foo');
305
+ expect(console.timeEnd.calls.count()).toBe(1);
306
+ expect(console.timeEnd.calls.argsFor(0)[0]).toBe('React mount: Foo');
307
} finally {
308
ReactFeatureFlags.logTopLevelRenders = false;
309
}
src/renderers/dom/client/__tests__/ReactMountDestruction-test.js
+4
-4
@@ -53,8 +53,8 @@ describe('ReactMount', function() {
53
var rootDiv = mainContainerDiv.firstChild;
54
spyOn(console, 'error');
55
ReactDOM.unmountComponentAtNode(rootDiv);
56
- expect(console.error.calls.length).toBe(1);
57
- expect(console.error.argsForCall[0][0]).toBe(
56
+ expect(console.error.calls.count()).toBe(1);
57
+ expect(console.error.calls.argsFor(0)[0]).toBe(
58
'Warning: unmountComponentAtNode(): The node you\'re attempting to ' +
59
'unmount was rendered by React and is not a top-level container. You ' +
60
'may have accidentally passed in a React root node instead of its ' +
@@ -77,8 +77,8 @@ describe('ReactMount', function() {
77
var nonRootDiv = mainContainerDiv.firstChild.firstChild;
78
spyOn(console, 'error');
79
ReactDOM.unmountComponentAtNode(nonRootDiv);
80
- expect(console.error.calls.length).toBe(1);
81
- expect(console.error.argsForCall[0][0]).toBe(
80
+ expect(console.error.calls.count()).toBe(1);
81
+ expect(console.error.calls.argsFor(0)[0]).toBe(
82
'Warning: unmountComponentAtNode(): The node you\'re attempting to ' +
83
'unmount was rendered by React and is not a top-level container. ' +
84
'Instead, have the parent component update its state and rerender in ' +
src/renderers/dom/client/__tests__/ReactRenderDocument-test.js
+4
-4
@@ -94,7 +94,7 @@ describe('rendering React components at document', function() {
94
95
expect(function() {
96
ReactDOM.unmountComponentAtNode(testDocument);
97
- }).toThrow(UNMOUNT_INVARIANT_MESSAGE);
97
+ }).toThrowError(UNMOUNT_INVARIANT_MESSAGE);
98
99
expect(testDocument.body.innerHTML).toBe('Hello world');
100
});
@@ -142,7 +142,7 @@ describe('rendering React components at document', function() {
142
// Reactive update
143
expect(function() {
144
ReactDOM.render(<Component2 />, testDocument);
145
- }).toThrow(UNMOUNT_INVARIANT_MESSAGE);
145
+ }).toThrowError(UNMOUNT_INVARIANT_MESSAGE);
146
147
expect(testDocument.body.innerHTML).toBe('Hello world');
148
});
@@ -201,7 +201,7 @@ describe('rendering React components at document', function() {
201
expect(function() {
202
// Notice the text is different!
203
ReactDOM.render(<Component text="Hello world" />, testDocument);
204
- }).toThrow(
204
+ }).toThrowError(
205
'You\'re trying to render a component to the document using ' +
206
'server rendering but the checksum was invalid. This usually ' +
207
'means you rendered a different component type or props on ' +
@@ -237,7 +237,7 @@ describe('rendering React components at document', function() {
237
238
expect(function() {
239
ReactDOM.render(<Component />, container);
240
- }).toThrow(
240
+ }).toThrowError(
241
'You\'re trying to render a component to the document but you didn\'t ' +
242
'use server rendering. We can\'t do this without using server ' +
243
'rendering due to cross-browser quirks. See ' +
src/renderers/dom/client/__tests__/findDOMNode-test.js
+2
-2
@@ -37,7 +37,7 @@ describe('findDOMNode', function() {
37
it('findDOMNode should reject random objects', function() {
38
expect(function() {
39
ReactDOM.findDOMNode({foo: 'bar'});
40
- }).toThrow(
40
+ }).toThrowError(
41
'Element appears to be neither ReactComponent nor DOMNode (keys: foo)'
42
);
43
});
@@ -53,7 +53,7 @@ describe('findDOMNode', function() {
53
var inst = ReactDOM.render(<Foo />, container);
54
ReactDOM.unmountComponentAtNode(container);
55
56
- expect(() => ReactDOM.findDOMNode(inst)).toThrow(
56
+ expect(() => ReactDOM.findDOMNode(inst)).toThrowError(
57
'findDOMNode was called on an unmounted component.'
58
);
59
});
src/renderers/dom/client/syntheticEvents/__tests__/SyntheticEvent-test.js
+14
-14
@@ -87,9 +87,9 @@ describe('SyntheticEvent', function() {
87
expect(syntheticEvent.nativeEvent).toBe(null);
88
expect(syntheticEvent.target).toBe(null);
89
// once for each property accessed
90
- expect(console.error.calls.length).toBe(3);
90
+ expect(console.error.calls.count()).toBe(3);
91
// assert the first warning for accessing `type`
92
- expect(console.error.argsForCall[0][0]).toBe(
92
+ expect(console.error.argsFor(0)[0]).toBe(
93
'Warning: This synthetic event is reused for performance reasons. If ' +
94
'you\'re seeing this, you\'re accessing the property `type` on a ' +
95
'released/nullified synthetic event. This is set to null. If you must ' +
@@ -104,8 +104,8 @@ describe('SyntheticEvent', function() {
104
var syntheticEvent = createEvent({srcElement: target});
105
syntheticEvent.destructor();
106
expect(syntheticEvent.type = 'MouseEvent').toBe('MouseEvent');
107
- expect(console.error.calls.length).toBe(1);
108
- expect(console.error.argsForCall[0][0]).toBe(
107
+ expect(console.error.calls.count()).toBe(1);
108
+ expect(console.error.argsFor(0)[0]).toBe(
109
'Warning: This synthetic event is reused for performance reasons. If ' +
110
'you\'re seeing this, you\'re setting the property `type` on a ' +
111
'released/nullified synthetic event. This is effectively a no-op. If you must ' +
@@ -119,8 +119,8 @@ describe('SyntheticEvent', function() {
119
var syntheticEvent = createEvent({});
120
SyntheticEvent.release(syntheticEvent);
121
syntheticEvent.preventDefault();
122
- expect(console.error.calls.length).toBe(1);
123
- expect(console.error.argsForCall[0][0]).toBe(
122
+ expect(console.error.calls.count()).toBe(1);
123
+ expect(console.error.argsFor(0)[0]).toBe(
124
'Warning: This synthetic event is reused for performance reasons. If ' +
125
'you\'re seeing this, you\'re accessing the method `preventDefault` on a ' +
126
'released/nullified synthetic event. This is a no-op function. If you must ' +
@@ -134,8 +134,8 @@ describe('SyntheticEvent', function() {
134
var syntheticEvent = createEvent({});
135
SyntheticEvent.release(syntheticEvent);
136
syntheticEvent.stopPropagation();
137
- expect(console.error.calls.length).toBe(1);
138
- expect(console.error.argsForCall[0][0]).toBe(
137
+ expect(console.error.calls.count()).toBe(1);
138
+ expect(console.error.argsFor(0)[0]).toBe(
139
'Warning: This synthetic event is reused for performance reasons. If ' +
140
'you\'re seeing this, you\'re accessing the method `stopPropagation` on a ' +
141
'released/nullified synthetic event. This is a no-op function. If you must ' +
@@ -156,13 +156,13 @@ describe('SyntheticEvent', function() {
156
}
157
var instance = ReactDOM.render(<div onClick={assignEvent} />, element);
158
ReactTestUtils.Simulate.click(ReactDOM.findDOMNode(instance));
159
- expect(console.error.calls.length).toBe(0);
159
+ expect(console.error.calls.count()).toBe(0);
160
161
// access a property to cause the warning
162
event.nativeEvent; // eslint-disable-line no-unused-expressions
163
164
- expect(console.error.calls.length).toBe(1);
165
- expect(console.error.argsForCall[0][0]).toBe(
164
+ expect(console.error.calls.count()).toBe(1);
165
+ expect(console.error.argsFor(0)[0]).toBe(
166
'Warning: This synthetic event is reused for performance reasons. If ' +
167
'you\'re seeing this, you\'re accessing the property `nativeEvent` on a ' +
168
'released/nullified synthetic event. This is set to null. If you must ' +
@@ -178,15 +178,15 @@ describe('SyntheticEvent', function() {
178
SyntheticEvent.release(syntheticEvent);
179
expect(syntheticEvent.foo).toBe('bar');
180
if (typeof Proxy === 'function') {
181
- expect(console.error.calls.length).toBe(1);
182
- expect(console.error.argsForCall[0][0]).toBe(
181
+ expect(console.error.calls.count()).toBe(1);
182
+ expect(console.error.argsFor(0)[0]).toBe(
183
'Warning: This synthetic event is reused for performance reasons. If ' +
184
'you\'re seeing this, you\'re adding a new property in the synthetic ' +
185
'event object. The property is never released. ' +
186
'See https://fb.me/react-event-pooling for more information.'
187
);
188
} else {
189
- expect(console.error.calls.length).toBe(0);
189
+ expect(console.error.calls.count()).toBe(0);
190
}
191
});
192
});
src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js
+39
-39
@@ -329,29 +329,29 @@ describe('ReactDOMInput', function() {
329
it('should warn with value and no onChange handler', function() {
330
var link = new ReactLink('yolo', jest.fn());
331
ReactTestUtils.renderIntoDocument(<input type="text" valueLink={link} />);
332
- expect(console.error.argsForCall.length).toBe(1);
333
- expect(console.error.argsForCall[0][0]).toContain(
332
+ expect(console.error.calls.count()).toBe(1);
333
+ expect(console.error.calls.argsFor(0)[0]).toContain(
334
'`valueLink` prop on `input` is deprecated; set `value` and `onChange` instead.'
335
);
336
337
ReactTestUtils.renderIntoDocument(
338
<input type="text" value="zoink" onChange={jest.fn()} />
339
);
340
- expect(console.error.argsForCall.length).toBe(1);
340
+ expect(console.error.calls.count()).toBe(1);
341
ReactTestUtils.renderIntoDocument(<input type="text" value="zoink" />);
342
- expect(console.error.argsForCall.length).toBe(2);
342
+ expect(console.error.calls.count()).toBe(2);
343
});
344
345
it('should warn with value and no onChange handler and readOnly specified', function() {
346
ReactTestUtils.renderIntoDocument(
347
<input type="text" value="zoink" readOnly={true} />
348
);
349
- expect(console.error.argsForCall.length).toBe(0);
349
+ expect(console.error.calls.count()).toBe(0);
350
351
ReactTestUtils.renderIntoDocument(
352
<input type="text" value="zoink" readOnly={false} />
353
);
354
- expect(console.error.argsForCall.length).toBe(1);
354
+ expect(console.error.calls.count()).toBe(1);
355
});
356
357
it('should have a this value of undefined if bind is not used', function() {
@@ -407,8 +407,8 @@ describe('ReactDOMInput', function() {
407
var node = document.createElement('div');
408
var link = new ReactLink(true, jest.fn());
409
ReactDOM.render(<input type="checkbox" checkedLink={link} />, node);
410
- expect(console.error.argsForCall.length).toBe(1);
411
- expect(console.error.argsForCall[0][0]).toContain(
410
+ expect(console.error.calls.count()).toBe(1);
411
+ expect(console.error.calls.argsFor(0)[0]).toContain(
412
'`checkedLink` prop on `input` is deprecated; set `value` and `onChange` instead.'
413
);
414
@@ -419,27 +419,27 @@ describe('ReactDOMInput', function() {
419
onChange={jest.fn()}
420
/>
421
);
422
- expect(console.error.argsForCall.length).toBe(1);
422
+ expect(console.error.calls.count()).toBe(1);
423
424
ReactTestUtils.renderIntoDocument(
425
<input type="checkbox" checked="false" readOnly={true} />
426
);
427
- expect(console.error.argsForCall.length).toBe(1);
427
+ expect(console.error.calls.count()).toBe(1);
428
429
ReactTestUtils.renderIntoDocument(<input type="checkbox" checked="false" />);
430
- expect(console.error.argsForCall.length).toBe(2);
430
+ expect(console.error.calls.count()).toBe(2);
431
});
432
433
it('should warn with checked and no onChange handler with readOnly specified', function() {
434
ReactTestUtils.renderIntoDocument(
435
<input type="checkbox" checked="false" readOnly={true} />
436
);
437
- expect(console.error.argsForCall.length).toBe(0);
437
+ expect(console.error.calls.count()).toBe(0);
438
439
ReactTestUtils.renderIntoDocument(
440
<input type="checkbox" checked="false" readOnly={false} />
441
);
442
- expect(console.error.argsForCall.length).toBe(1);
442
+ expect(console.error.calls.count()).toBe(1);
443
});
444
445
it('should throw if both checked and checkedLink are provided', function() {
@@ -488,21 +488,21 @@ describe('ReactDOMInput', function() {
488
489
it('should warn if value is null', function() {
490
ReactTestUtils.renderIntoDocument(<input type="text" value={null} />);
491
- expect(console.error.argsForCall[0][0]).toContain(
491
+ expect(console.error.calls.argsFor(0)[0]).toContain(
492
'`value` prop on `input` should not be null. ' +
493
'Consider using the empty string to clear the component or `undefined` ' +
494
'for uncontrolled components.'
495
);
496
497
ReactTestUtils.renderIntoDocument(<input type="text" value={null} />);
498
- expect(console.error.argsForCall.length).toBe(1);
498
+ expect(console.error.calls.count()).toBe(1);
499
});
500
501
it('should warn if checked and defaultChecked props are specified', function() {
502
ReactTestUtils.renderIntoDocument(
503
<input type="radio" checked={true} defaultChecked={true} readOnly={true} />
504
);
505
- expect(console.error.argsForCall[0][0]).toContain(
505
+ expect(console.error.calls.argsFor(0)[0]).toContain(
506
'A component contains an input of type radio with both checked and defaultChecked props. ' +
507
'Input elements must be either controlled or uncontrolled ' +
508
'(specify either the checked prop, or the defaultChecked prop, but not ' +
@@ -514,14 +514,14 @@ describe('ReactDOMInput', function() {
514
ReactTestUtils.renderIntoDocument(
515
<input type="radio" checked={true} defaultChecked={true} readOnly={true} />
516
);
517
- expect(console.error.argsForCall.length).toBe(1);
517
+ expect(console.error.calls.count()).toBe(1);
518
});
519
520
it('should warn if value and defaultValue props are specified', function() {
521
ReactTestUtils.renderIntoDocument(
522
<input type="text" value="foo" defaultValue="bar" readOnly={true} />
523
);
524
- expect(console.error.argsForCall[0][0]).toContain(
524
+ expect(console.error.calls.argsFor(0)[0]).toContain(
525
'A component contains an input of type text with both value and defaultValue props. ' +
526
'Input elements must be either controlled or uncontrolled ' +
527
'(specify either the value prop, or the defaultValue prop, but not ' +
@@ -533,7 +533,7 @@ describe('ReactDOMInput', function() {
533
ReactTestUtils.renderIntoDocument(
534
<input type="text" value="foo" defaultValue="bar" readOnly={true} />
535
);
536
- expect(console.error.argsForCall.length).toBe(1);
536
+ expect(console.error.calls.count()).toBe(1);
537
});
538
539
it('should warn if controlled input switches to uncontrolled', function() {
@@ -541,8 +541,8 @@ describe('ReactDOMInput', function() {
541
var container = document.createElement('div');
542
ReactDOM.render(stub, container);
543
ReactDOM.render(<input type="text" />, container);
544
- expect(console.error.argsForCall.length).toBe(1);
545
- expect(console.error.argsForCall[0][0]).toContain(
544
+ expect(console.error.calls.count()).toBe(1);
545
+ expect(console.error.calls.argsFor(0)[0]).toContain(
546
'A component is changing a controlled input of type text to be uncontrolled. ' +
547
'Input elements should not switch from controlled to uncontrolled (or vice versa). ' +
548
'Decide between using a controlled or uncontrolled input ' +
@@ -555,8 +555,8 @@ describe('ReactDOMInput', function() {
555
var container = document.createElement('div');
556
ReactDOM.render(stub, container);
557
ReactDOM.render(<input type="text" defaultValue="uncontrolled" />, container);
558
- expect(console.error.argsForCall.length).toBe(1);
559
- expect(console.error.argsForCall[0][0]).toContain(
558
+ expect(console.error.calls.count()).toBe(1);
559
+ expect(console.error.calls.argsFor(0)[0]).toContain(
560
'A component is changing a controlled input of type text to be uncontrolled. ' +
561
'Input elements should not switch from controlled to uncontrolled (or vice versa). ' +
562
'Decide between using a controlled or uncontrolled input ' +
@@ -569,8 +569,8 @@ describe('ReactDOMInput', function() {
569
var container = document.createElement('div');
570
ReactDOM.render(stub, container);
571
ReactDOM.render(<input type="text" value="controlled" />, container);
572
- expect(console.error.argsForCall.length).toBe(1);
573
- expect(console.error.argsForCall[0][0]).toContain(
572
+ expect(console.error.calls.count()).toBe(1);
573
+ expect(console.error.calls.argsFor(0)[0]).toContain(
574
'A component is changing an uncontrolled input of type text to be controlled. ' +
575
'Input elements should not switch from uncontrolled to controlled (or vice versa). ' +
576
'Decide between using a controlled or uncontrolled input ' +
@@ -583,8 +583,8 @@ describe('ReactDOMInput', function() {
583
var container = document.createElement('div');
584
ReactDOM.render(stub, container);
585
ReactDOM.render(<input type="checkbox" />, container);
586
- expect(console.error.argsForCall.length).toBe(1);
587
- expect(console.error.argsForCall[0][0]).toContain(
586
+ expect(console.error.calls.count()).toBe(1);
587
+ expect(console.error.calls.argsFor(0)[0]).toContain(
588
'A component is changing a controlled input of type checkbox to be uncontrolled. ' +
589
'Input elements should not switch from controlled to uncontrolled (or vice versa). ' +
590
'Decide between using a controlled or uncontrolled input ' +
@@ -597,8 +597,8 @@ describe('ReactDOMInput', function() {
597
var container = document.createElement('div');
598
ReactDOM.render(stub, container);
599
ReactDOM.render(<input type="checkbox" defaultChecked={true} />, container);
600
- expect(console.error.argsForCall.length).toBe(1);
601
- expect(console.error.argsForCall[0][0]).toContain(
600
+ expect(console.error.calls.count()).toBe(1);
601
+ expect(console.error.calls.argsFor(0)[0]).toContain(
602
'A component is changing a controlled input of type checkbox to be uncontrolled. ' +
603
'Input elements should not switch from controlled to uncontrolled (or vice versa). ' +
604
'Decide between using a controlled or uncontrolled input ' +
@@ -611,8 +611,8 @@ describe('ReactDOMInput', function() {
611
var container = document.createElement('div');
612
ReactDOM.render(stub, container);
613
ReactDOM.render(<input type="checkbox" checked={true} />, container);
614
- expect(console.error.argsForCall.length).toBe(1);
615
- expect(console.error.argsForCall[0][0]).toContain(
614
+ expect(console.error.calls.count()).toBe(1);
615
+ expect(console.error.calls.argsFor(0)[0]).toContain(
616
'A component is changing an uncontrolled input of type checkbox to be controlled. ' +
617
'Input elements should not switch from uncontrolled to controlled (or vice versa). ' +
618
'Decide between using a controlled or uncontrolled input ' +
@@ -625,8 +625,8 @@ describe('ReactDOMInput', function() {
625
var container = document.createElement('div');
626
ReactDOM.render(stub, container);
627
ReactDOM.render(<input type="radio" />, container);
628
- expect(console.error.argsForCall.length).toBe(1);
629
- expect(console.error.argsForCall[0][0]).toContain(
628
+ expect(console.error.calls.count()).toBe(1);
629
+ expect(console.error.calls.argsFor(0)[0]).toContain(
630
'A component is changing a controlled input of type radio to be uncontrolled. ' +
631
'Input elements should not switch from controlled to uncontrolled (or vice versa). ' +
632
'Decide between using a controlled or uncontrolled input ' +
@@ -639,8 +639,8 @@ describe('ReactDOMInput', function() {
639
var container = document.createElement('div');
640
ReactDOM.render(stub, container);
641
ReactDOM.render(<input type="radio" defaultChecked={true} />, container);
642
- expect(console.error.argsForCall.length).toBe(1);
643
- expect(console.error.argsForCall[0][0]).toContain(
642
+ expect(console.error.calls.count()).toBe(1);
643
+ expect(console.error.calls.argsFor(0)[0]).toContain(
644
'A component is changing a controlled input of type radio to be uncontrolled. ' +
645
'Input elements should not switch from controlled to uncontrolled (or vice versa). ' +
646
'Decide between using a controlled or uncontrolled input ' +
@@ -653,8 +653,8 @@ describe('ReactDOMInput', function() {
653
var container = document.createElement('div');
654
ReactDOM.render(stub, container);
655
ReactDOM.render(<input type="radio" checked={true} />, container);
656
- expect(console.error.argsForCall.length).toBe(1);
657
- expect(console.error.argsForCall[0][0]).toContain(
656
+ expect(console.error.calls.count()).toBe(1);
657
+ expect(console.error.calls.argsFor(0)[0]).toContain(
658
'A component is changing an uncontrolled input of type radio to be controlled. ' +
659
'Input elements should not switch from uncontrolled to controlled (or vice versa). ' +
660
'Decide between using a controlled or uncontrolled input ' +
@@ -668,7 +668,7 @@ describe('ReactDOMInput', function() {
668
}
669
var log = [];
670
var originalCreateElement = document.createElement;
671
- spyOn(document, 'createElement').andCallFake(function(type) {
671
+ spyOn(document, 'createElement').and.callFake(function(type) {
672
var el = originalCreateElement.apply(this, arguments);
673
if (type === 'input') {
674
Object.defineProperty(el, 'value', {
@@ -677,7 +677,7 @@ describe('ReactDOMInput', function() {
677
log.push('set value');
678
},
679
});
680
- spyOn(el, 'setAttribute').andCallFake(function(name, value) {
680
+ spyOn(el, 'setAttribute').and.callFake(function(name, value) {
681
log.push('set ' + name);
682
});
683
}
src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js
+4
-4
@@ -39,8 +39,8 @@ describe('ReactDOMOption', function() {
39
expect(node.innerHTML).toBe('1 2');
40
ReactTestUtils.renderIntoDocument(<option>{1} <div /> {2}</option>);
41
// only warn once
42
- expect(console.error.calls.length).toBe(1);
43
- expect(console.error.argsForCall[0][0]).toContain('Only strings and numbers are supported as <option> children.');
42
+ expect(console.error.calls.count()).toBe(1);
43
+ expect(console.error.calls.argsFor(0)[0]).toContain('Only strings and numbers are supported as <option> children.');
44
});
45
46
it('should ignore null/undefined/false children without warning', function() {
@@ -50,7 +50,7 @@ describe('ReactDOMOption', function() {
50
51
var node = ReactDOM.findDOMNode(stub);
52
53
- expect(console.error.calls.length).toBe(0);
53
+ expect(console.error.calls.count()).toBe(0);
54
expect(node.innerHTML).toBe('1 2');
55
});
56
@@ -93,5 +93,5 @@ describe('ReactDOMOption', function() {
93
container
94
);
95
expect(node.selectedIndex).toEqual(2);
96
- });
96
+ });
97
});
src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js
+6
-6
@@ -360,8 +360,8 @@ describe('ReactDOMSelect', function() {
360
361
stub = ReactTestUtils.renderIntoDocument(stub);
362
363
- expect(console.error.argsForCall.length).toBe(1);
364
- expect(console.error.argsForCall[0][0]).toContain(
363
+ expect(console.error.calls.count()).toBe(1);
364
+ expect(console.error.calls.argsFor(0)[0]).toContain(
365
'`valueLink` prop on `select` is deprecated; set `value` and `onChange` instead.'
366
);
367
@@ -466,14 +466,14 @@ describe('ReactDOMSelect', function() {
466
spyOn(console, 'error');
467
468
ReactTestUtils.renderIntoDocument(<select value={null}><option value="test"/></select>);
469
- expect(console.error.argsForCall[0][0]).toContain(
469
+ expect(console.error.calls.argsFor(0)[0]).toContain(
470
'`value` prop on `select` should not be null. ' +
471
'Consider using the empty string to clear the component or `undefined` ' +
472
'for uncontrolled components.'
473
);
474
475
ReactTestUtils.renderIntoDocument(<select value={null}><option value="test"/></select>);
476
- expect(console.error.argsForCall.length).toBe(1);
476
+ expect(console.error.calls.count()).toBe(1);
477
});
478
479
it('should refresh state on change', function() {
@@ -500,7 +500,7 @@ describe('ReactDOMSelect', function() {
500
<option value="gorilla">A gorilla!</option>
501
</select>
502
);
503
- expect(console.error.argsForCall[0][0]).toContain(
503
+ expect(console.error.calls.argsFor(0)[0]).toContain(
504
'Select elements must be either controlled or uncontrolled ' +
505
'(specify either the value prop, or the defaultValue prop, but not ' +
506
'both). Decide between using a controlled or uncontrolled select ' +
@@ -515,7 +515,7 @@ describe('ReactDOMSelect', function() {
515
<option value="gorilla">A gorilla!</option>
516
</select>
517
);
518
- expect(console.error.argsForCall.length).toBe(1);
518
+ expect(console.error.calls.count()).toBe(1);
519
});
520
521
it('should be able to safely remove select onChange', function() {
src/renderers/dom/client/wrappers/__tests__/ReactDOMTextarea-test.js
+12
-12
@@ -257,7 +257,7 @@ describe('ReactDOMTextarea', function() {
257
var stub = <textarea>giraffe</textarea>;
258
var node = renderTextarea(stub, container);
259
260
- expect(console.error.argsForCall.length).toBe(1);
260
+ expect(console.error.calls.count()).toBe(1);
261
expect(node.value).toBe('giraffe');
262
263
// Changing children should do nothing, it functions like `defaultValue`.
@@ -296,14 +296,14 @@ describe('ReactDOMTextarea', function() {
296
it('should allow numbers as children', function() {
297
spyOn(console, 'error');
298
var node = renderTextarea(<textarea>{17}</textarea>);
299
- expect(console.error.argsForCall.length).toBe(1);
299
+ expect(console.error.calls.count()).toBe(1);
300
expect(node.value).toBe('17');
301
});
302
303
it('should allow booleans as children', function() {
304
spyOn(console, 'error');
305
var node = renderTextarea(<textarea>{false}</textarea>);
306
- expect(console.error.argsForCall.length).toBe(1);
306
+ expect(console.error.calls.count()).toBe(1);
307
expect(node.value).toBe('false');
308
});
309
@@ -315,7 +315,7 @@ describe('ReactDOMTextarea', function() {
315
},
316
};
317
var node = renderTextarea(<textarea>{obj}</textarea>);
318
- expect(console.error.argsForCall.length).toBe(1);
318
+ expect(console.error.calls.count()).toBe(1);
319
expect(node.value).toBe('sharkswithlasers');
320
});
321
@@ -328,7 +328,7 @@ describe('ReactDOMTextarea', function() {
328
);
329
}).toThrow();
330
331
- expect(console.error.argsForCall.length).toBe(1);
331
+ expect(console.error.calls.count()).toBe(1);
332
333
var node;
334
expect(function() {
@@ -337,7 +337,7 @@ describe('ReactDOMTextarea', function() {
337
338
expect(node.value).toBe('[object Object]');
339
340
- expect(console.error.argsForCall.length).toBe(2);
340
+ expect(console.error.calls.count()).toBe(2);
341
});
342
343
it('should support ReactLink', function() {
@@ -346,8 +346,8 @@ describe('ReactDOMTextarea', function() {
346
347
spyOn(console, 'error');
348
instance = renderTextarea(instance);
349
- expect(console.error.argsForCall.length).toBe(1);
350
- expect(console.error.argsForCall[0][0]).toContain(
349
+ expect(console.error.calls.count()).toBe(1);
350
+ expect(console.error.calls.argsFor(0)[0]).toContain(
351
'`valueLink` prop on `textarea` is deprecated; set `value` and `onChange` instead.'
352
);
353
@@ -373,14 +373,14 @@ describe('ReactDOMTextarea', function() {
373
spyOn(console, 'error');
374
375
ReactTestUtils.renderIntoDocument(<textarea value={null} />);
376
- expect(console.error.argsForCall[0][0]).toContain(
376
+ expect(console.error.calls.argsFor(0)[0]).toContain(
377
'`value` prop on `textarea` should not be null. ' +
378
'Consider using the empty string to clear the component or `undefined` ' +
379
'for uncontrolled components.'
380
);
381
382
ReactTestUtils.renderIntoDocument(<textarea value={null} />);
383
- expect(console.error.argsForCall.length).toBe(1);
383
+ expect(console.error.calls.count()).toBe(1);
384
});
385
386
it('should warn if value and defaultValue are specified', function() {
@@ -388,7 +388,7 @@ describe('ReactDOMTextarea', function() {
388
ReactTestUtils.renderIntoDocument(
389
<textarea value="foo" defaultValue="bar" readOnly={true} />
390
);
391
- expect(console.error.argsForCall[0][0]).toContain(
391
+ expect(console.error.calls.argsFor(0)[0]).toContain(
392
'Textarea elements must be either controlled or uncontrolled ' +
393
'(specify either the value prop, or the defaultValue prop, but not ' +
394
'both). Decide between using a controlled or uncontrolled textarea ' +
@@ -399,7 +399,7 @@ describe('ReactDOMTextarea', function() {
399
ReactTestUtils.renderIntoDocument(
400
<textarea value="foo" defaultValue="bar" readOnly={true} />
401
);
402
- expect(console.error.argsForCall.length).toBe(1);
402
+ expect(console.error.calls.count()).toBe(1);
403
});
404
405
});
src/renderers/dom/server/__tests__/ReactServerRendering-test.js
+3
-3
@@ -250,7 +250,7 @@ describe('ReactServerRendering', function() {
250
spyOn(console, 'error');
251
instance = ReactDOM.render(<TestComponent name="y" />, element);
252
expect(mountCount).toEqual(4);
253
- expect(console.error.argsForCall.length).toBe(1);
253
+ expect(console.error.calls.count()).toBe(1);
254
expect(element.innerHTML.length > 0).toBe(true);
255
expect(element.innerHTML).not.toEqual(lastMarkup);
256
@@ -266,7 +266,7 @@ describe('ReactServerRendering', function() {
266
ReactServerRendering,
267
'not a component'
268
)
269
- ).toThrow(
269
+ ).toThrowError(
270
'renderToString(): You must pass a valid ReactElement.'
271
);
272
});
@@ -375,7 +375,7 @@ describe('ReactServerRendering', function() {
375
ReactServerRendering,
376
'not a component'
377
)
378
- ).toThrow(
378
+ ).toThrowError(
379
'renderToStaticMarkup(): You must pass a valid ReactElement.'
380
);
381
});
src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
+13
-13
@@ -117,8 +117,8 @@ describe('CSSPropertyOperations', function() {
117
spyOn(console, 'error');
118
var root = document.createElement('div');
119
ReactDOM.render(<Comp />, root);
120
- expect(console.error.argsForCall.length).toBe(1);
121
- expect(console.error.argsForCall[0][0]).toEqual(
120
+ expect(console.error.calls.count()).toBe(1);
121
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
122
'Warning: Unsupported style property background-color. Did you mean backgroundColor? ' +
123
'Check the render method of `Comp`.'
124
);
@@ -140,12 +140,12 @@ describe('CSSPropertyOperations', function() {
140
ReactDOM.render(<Comp />, root);
141
ReactDOM.render(<Comp style={styles} />, root);
142
143
- expect(console.error.argsForCall.length).toBe(2);
144
- expect(console.error.argsForCall[0][0]).toEqual(
143
+ expect(console.error.calls.count()).toBe(2);
144
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
145
'Warning: Unsupported style property -ms-transform. Did you mean msTransform? ' +
146
'Check the render method of `Comp`.'
147
);
148
- expect(console.error.argsForCall[1][0]).toEqual(
148
+ expect(console.error.calls.argsFor(1)[0]).toEqual(
149
'Warning: Unsupported style property -webkit-transform. Did you mean WebkitTransform? ' +
150
'Check the render method of `Comp`.'
151
);
@@ -166,12 +166,12 @@ describe('CSSPropertyOperations', function() {
166
var root = document.createElement('div');
167
ReactDOM.render(<Comp />, root);
168
// msTransform is correct already and shouldn't warn
169
- expect(console.error.argsForCall.length).toBe(2);
170
- expect(console.error.argsForCall[0][0]).toEqual(
169
+ expect(console.error.calls.count()).toBe(2);
170
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
171
'Warning: Unsupported vendor-prefixed style property oTransform. ' +
172
'Did you mean OTransform? Check the render method of `Comp`.'
173
);
174
- expect(console.error.argsForCall[1][0]).toEqual(
174
+ expect(console.error.calls.argsFor(1)[0]).toEqual(
175
'Warning: Unsupported vendor-prefixed style property webkitTransform. ' +
176
'Did you mean WebkitTransform? Check the render method of `Comp`.'
177
);
@@ -192,12 +192,12 @@ describe('CSSPropertyOperations', function() {
192
spyOn(console, 'error');
193
var root = document.createElement('div');
194
ReactDOM.render(<Comp />, root);
195
- expect(console.error.calls.length).toBe(2);
196
- expect(console.error.argsForCall[0][0]).toEqual(
195
+ expect(console.error.calls.count()).toBe(2);
196
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
197
'Warning: Style property values shouldn\'t contain a semicolon. ' +
198
'Check the render method of `Comp`. Try "backgroundColor: blue" instead.',
199
);
200
- expect(console.error.argsForCall[1][0]).toEqual(
200
+ expect(console.error.calls.argsFor(1)[0]).toEqual(
201
'Warning: Style property values shouldn\'t contain a semicolon. ' +
202
'Check the render method of `Comp`. Try "color: red" instead.',
203
);
@@ -214,8 +214,8 @@ describe('CSSPropertyOperations', function() {
214
var root = document.createElement('div');
215
ReactDOM.render(<Comp />, root);
216
217
- expect(console.error.calls.length).toBe(1);
218
- expect(console.error.argsForCall[0][0]).toEqual(
217
+ expect(console.error.calls.count()).toBe(1);
218
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
219
'Warning: `NaN` is an invalid value for the `fontSize` css style property. ' +
220
'Check the render method of `Comp`.'
221
);
src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js
+2
-2
@@ -200,8 +200,8 @@ describe('DOMPropertyOperations', function() {
200
'xlinkHref',
201
'about:blank'
202
);
203
- expect(stubNode.setAttributeNS.argsForCall.length).toBe(1);
204
- expect(stubNode.setAttributeNS.argsForCall[0])
203
+ expect(stubNode.setAttributeNS.calls.count()).toBe(1);
204
+ expect(stubNode.setAttributeNS.calls.argsFor(0))
205
.toEqual(['http://www.w3.org/1999/xlink', 'xlink:href', 'about:blank']);
206
});
207
src/renderers/dom/shared/__tests__/Danger-test.js
+3
-3
@@ -78,19 +78,19 @@ describe('Danger', function() {
78
it('should throw when rendering invalid markup', function() {
79
expect(function() {
80
Danger.dangerouslyRenderMarkup(['']);
81
- }).toThrow(
81
+ }).toThrowError(
82
'dangerouslyRenderMarkup(...): Missing markup.'
83
);
84
85
spyOn(console, 'error');
86
87
var renderedMarkup = Danger.dangerouslyRenderMarkup(['<p></p><p></p>']);
88
- var args = console.error.argsForCall[0];
88
+ var args = console.error.calls.argsFor(0);
89
90
expect(renderedMarkup.length).toBe(1);
91
expect(renderedMarkup[0].nodeName).toBe('P');
92
93
- expect(console.error.argsForCall.length).toBe(1);
93
+ expect(console.error.calls.count()).toBe(1);
94
95
expect(args.length).toBe(2);
96
expect(args[0]).toBe('Danger: Discarding unexpected node:');
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+120
-107
@@ -128,8 +128,8 @@ describe('ReactDOMComponent', function() {
128
var stub = ReactTestUtils.renderIntoDocument(<App />);
129
style.position = 'absolute';
130
stub.setState({style: style});
131
- expect(console.error.argsForCall.length).toBe(1);
132
- expect(console.error.argsForCall[0][0]).toEqual(
131
+ expect(console.error.calls.count()).toBe(1);
132
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
133
'Warning: `div` was passed a style object that has previously been ' +
134
'mutated. Mutating `style` is deprecated. Consider cloning it ' +
135
'beforehand. Check the `render` of `App`. Previous style: ' +
@@ -142,22 +142,22 @@ describe('ReactDOMComponent', function() {
142
style.background = 'green';
143
stub.setState({style: {background: 'green'}});
144
// already warned once for the same component and owner
145
- expect(console.error.argsForCall.length).toBe(1);
145
+ expect(console.error.calls.count()).toBe(1);
146
147
style = {background: 'red'};
148
var div = document.createElement('div');
149
ReactDOM.render(<span style={style}></span>, div);
150
style.background = 'blue';
151
ReactDOM.render(<span style={style}></span>, div);
152
- expect(console.error.argsForCall.length).toBe(2);
152
+ expect(console.error.calls.count()).toBe(2);
153
});
154
155
it('should warn for unknown prop', function() {
156
spyOn(console, 'error');
157
var container = document.createElement('div');
158
ReactDOM.render(<div foo="bar" />, container);
159
- expect(console.error.argsForCall.length).toBe(1);
160
- expect(normalizeCodeLocInfo(console.error.argsForCall[0][0])).toBe(
159
+ expect(console.error.calls.count(0)).toBe(1);
160
+ expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
161
'Warning: Unknown prop `foo` on <div> tag. Remove this prop from the element. ' +
162
'For details, see https://fb.me/react-unknown-prop\n in div (at **)'
163
);
@@ -180,8 +180,8 @@ describe('ReactDOMComponent', function() {
180
},
181
});
182
ReactDOM.render(<One inline={false} />, div);
183
- expect(console.error.calls.length).toBe(1);
184
- expect(console.error.argsForCall[0][0]).toBe(
183
+ expect(console.error.calls.count()).toBe(1);
184
+ expect(console.error.calls.argsFor(0)[0]).toBe(
185
'Warning: a `div` tag (owner: `One`) was passed a numeric string value ' +
186
'for CSS property `fontSize` (value: `1`) which will be treated ' +
187
'as a unitless number in a future version of React.'
@@ -189,12 +189,12 @@ describe('ReactDOMComponent', function() {
189
190
// Don't warn again for the same component
191
ReactDOM.render(<One inline={true} />, div);
192
- expect(console.error.calls.length).toBe(1);
192
+ expect(console.error.calls.count()).toBe(1);
193
194
// Do warn for different components
195
ReactDOM.render(<Two />, div);
196
- expect(console.error.calls.length).toBe(2);
197
- expect(console.error.argsForCall[1][0]).toBe(
196
+ expect(console.error.calls.count()).toBe(2);
197
+ expect(console.error.calls.argsFor(1)[0]).toBe(
198
'Warning: a `div` tag (owner: `Two`) was passed a numeric string value ' +
199
'for CSS property `fontSize` (value: `1`) which will be treated ' +
200
'as a unitless number in a future version of React.'
@@ -202,7 +202,7 @@ describe('ReactDOMComponent', function() {
202
203
// Really don't warn again for the same component
204
ReactDOM.render(<One inline={true} />, div);
205
- expect(console.error.calls.length).toBe(2);
205
+ expect(console.error.calls.count()).toBe(2);
206
});
207
208
it('should warn nicely about NaN in style', function() {
@@ -213,8 +213,8 @@ describe('ReactDOMComponent', function() {
213
ReactDOM.render(<span style={style}></span>, div);
214
ReactDOM.render(<span style={style}></span>, div);
215
216
- expect(console.error.argsForCall.length).toBe(1);
217
- expect(console.error.argsForCall[0][0]).toEqual(
216
+ expect(console.error.calls.count()).toBe(1);
217
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
218
'Warning: `NaN` is an invalid value for the `fontSize` css style property.',
219
);
220
});
@@ -352,8 +352,8 @@ describe('ReactDOMComponent', function() {
352
);
353
ReactDOM.render(element, container);
354
}
355
- expect(console.error.argsForCall.length).toBe(1);
356
- expect(console.error.argsForCall[0][0]).toEqual(
355
+ expect(console.error.calls.count()).toBe(1);
356
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
357
'Warning: Invalid attribute name: `blah" onclick="beevil" noise="hi`'
358
);
359
});
@@ -372,8 +372,8 @@ describe('ReactDOMComponent', function() {
372
);
373
ReactDOM.render(afterUpdate, container);
374
}
375
- expect(console.error.argsForCall.length).toBe(1);
376
- expect(console.error.argsForCall[0][0]).toEqual(
375
+ expect(console.error.calls.count()).toBe(1);
376
+ expect(console.error.calls.argsFor(0)[0]).toEqual(
377
'Warning: Invalid attribute name: `blah" onclick="beevil" noise="hi`'
378
);
379
});
@@ -654,27 +654,34 @@ describe('ReactDOMComponent', function() {
654
);
655
};
656
657
- this.addMatchers({
658
- toHaveAttribute: function(attr, value) {
659
- var expected = '(?:^|\\s)' + attr + '=[\\\'"]';
660
- if (typeof value !== 'undefined') {
661
- expected += quoteRegexp(value) + '[\\\'"]';
662
- }
663
- return this.actual.match(new RegExp(expected));
657
+ jasmine.addMatchers({
658
+ toHaveAttribute() {
659
+ return {
660
+ compare(actual, expected) {
661
+ var [attr, value] = expected;
662
+ var re = '(?:^|\\s)' + attr + '=[\\\'"]';
663
+ if (typeof value !== 'undefined') {
664
+ re += quoteRegexp(value) + '[\\\'"]';
665
+ }
666
+ return {
667
+ pass: (new RegExp(re)).test(actual),
668
+ };
669
+ },
670
+ };
671
},
672
});
673
});
674
675
it('should generate the correct markup with className', function() {
669
- expect(genMarkup({className: 'a'})).toHaveAttribute('class', 'a');
670
- expect(genMarkup({className: 'a b'})).toHaveAttribute('class', 'a b');
671
- expect(genMarkup({className: ''})).toHaveAttribute('class', '');
676
+ expect(genMarkup({className: 'a'})).toHaveAttribute(['class', 'a']);
677
+ expect(genMarkup({className: 'a b'})).toHaveAttribute(['class', 'a b']);
678
+ expect(genMarkup({className: ''})).toHaveAttribute(['class', '']);
679
});
680
681
it('should escape style names and values', function() {
682
expect(genMarkup({
683
style: {'b&ckground': '<3'},
677
- })).toHaveAttribute('style', 'b&ckground:<3;');
684
+ })).toHaveAttribute(['style', 'b&ckground:<3;']);
685
});
686
});
687
@@ -704,10 +711,16 @@ describe('ReactDOMComponent', function() {
711
);
712
};
713
707
- this.addMatchers({
708
- toHaveInnerhtml: function(html) {
709
- var expected = '^' + quoteRegexp(html) + '$';
710
- return this.actual.match(new RegExp(expected));
714
+ jasmine.addMatchers({
715
+ toHaveInnerhtml() {
716
+ return {
717
+ compare(actual, expected) {
718
+ var re = '^' + quoteRegexp(expected) + '$';
719
+ return {
720
+ pass: (new RegExp(re)).test(actual),
721
+ };
722
+ },
723
+ };
724
},
725
});
726
});
@@ -745,7 +758,7 @@ describe('ReactDOMComponent', function() {
758
759
expect(function() {
760
ReactDOM.render(<input>children</input>, container);
748
- }).toThrow(
761
+ }).toThrowError(
762
'input is a void element tag and must not have `children` or ' +
763
'use `props.dangerouslySetInnerHTML`.'
764
);
@@ -759,7 +772,7 @@ describe('ReactDOMComponent', function() {
772
<input dangerouslySetInnerHTML={{__html: 'content'}} />,
773
container
774
);
762
- }).toThrow(
775
+ }).toThrowError(
776
'input is a void element tag and must not have `children` or use ' +
777
'`props.dangerouslySetInnerHTML`.'
778
);
@@ -774,7 +787,7 @@ describe('ReactDOMComponent', function() {
787
788
expect(function() {
789
ReactDOM.render(<menu><menuitem>children</menuitem></menu>, container);
777
- }).toThrow(
790
+ }).toThrowError(
791
'menuitem is a void element tag and must not have `children` or use ' +
792
'`props.dangerouslySetInnerHTML`.'
793
);
@@ -784,7 +797,7 @@ describe('ReactDOMComponent', function() {
797
it('should validate against multiple children props', function() {
798
expect(function() {
799
mountComponent({children: '', dangerouslySetInnerHTML: ''});
787
- }).toThrow(
800
+ }).toThrowError(
801
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
802
);
803
});
@@ -793,8 +806,8 @@ describe('ReactDOMComponent', function() {
806
807
spyOn(console, 'error');
808
mountComponent({innerHTML: '<span>Hi Jim!</span>'});
796
- expect(console.error.argsForCall.length).toBe(1);
797
- expect(console.error.argsForCall[0][0]).toContain(
809
+ expect(console.error.calls.count()).toBe(1);
810
+ expect(console.error.calls.argsFor(0)[0]).toContain(
811
'Directly setting property `innerHTML` is not permitted. '
812
);
813
});
@@ -802,7 +815,7 @@ describe('ReactDOMComponent', function() {
815
it('should validate use of dangerouslySetInnerHTML', function() {
816
expect(function() {
817
mountComponent({dangerouslySetInnerHTML: '<span>Hi Jim!</span>'});
805
- }).toThrow(
818
+ }).toThrowError(
819
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
820
'Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.'
821
);
@@ -811,7 +824,7 @@ describe('ReactDOMComponent', function() {
824
it('should validate use of dangerouslySetInnerHTML', function() {
825
expect(function() {
826
mountComponent({dangerouslySetInnerHTML: {foo: 'bar'} });
814
- }).toThrow(
827
+ }).toThrowError(
828
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
829
'Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.'
830
);
@@ -826,20 +839,20 @@ describe('ReactDOMComponent', function() {
839
it('should warn about contentEditable and children', function() {
840
spyOn(console, 'error');
841
mountComponent({contentEditable: true, children: ''});
829
- expect(console.error.argsForCall.length).toBe(1);
830
- expect(console.error.argsForCall[0][0]).toContain('contentEditable');
842
+ expect(console.error.calls.count()).toBe(1);
843
+ expect(console.error.calls.argsFor(0)[0]).toContain('contentEditable');
844
});
845
846
it('should respect suppressContentEditableWarning', function() {
847
spyOn(console, 'error');
848
mountComponent({contentEditable: true, children: '', suppressContentEditableWarning: true});
836
- expect(console.error.argsForCall.length).toBe(0);
849
+ expect(console.error.calls.count()).toBe(0);
850
});
851
852
it('should validate against invalid styles', function() {
853
expect(function() {
854
mountComponent({style: 'display: none'});
842
- }).toThrow(
855
+ }).toThrowError(
856
'The `style` prop expects a mapping from style properties to values, ' +
857
'not a string. For example, style={{marginRight: spacing + \'em\'}} ' +
858
'when using JSX.'
@@ -929,7 +942,7 @@ describe('ReactDOMComponent', function() {
942
var container = document.createElement('div');
943
expect(function() {
944
ReactDOM.render(<X />, container);
932
- }).toThrow(
945
+ }).toThrowError(
946
'input is a void element tag and must not have `children` ' +
947
'or use `props.dangerouslySetInnerHTML`. Check the render method of X.'
948
);
@@ -959,7 +972,7 @@ describe('ReactDOMComponent', function() {
972
973
expect(function() {
974
ReactDOM.render(<input>children</input>, container);
962
- }).toThrow(
975
+ }).toThrowError(
976
'input is a void element tag and must not have `children` or use ' +
977
'`props.dangerouslySetInnerHTML`.'
978
);
@@ -973,7 +986,7 @@ describe('ReactDOMComponent', function() {
986
<input dangerouslySetInnerHTML={{__html: 'content'}} />,
987
container
988
);
976
- }).toThrow(
989
+ }).toThrowError(
990
'input is a void element tag and must not have `children` or use ' +
991
'`props.dangerouslySetInnerHTML`.'
992
);
@@ -987,7 +1000,7 @@ describe('ReactDOMComponent', function() {
1000
<div children="" dangerouslySetInnerHTML={{__html: ''}}></div>,
1001
container
1002
);
990
- }).toThrow(
1003
+ }).toThrowError(
1004
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
1005
);
1006
});
@@ -998,8 +1011,8 @@ describe('ReactDOMComponent', function() {
1011
<div contentEditable={true}><div /></div>,
1012
container
1013
);
1001
- expect(console.error.argsForCall.length).toBe(1);
1002
- expect(console.error.argsForCall[0][0]).toContain('contentEditable');
1014
+ expect(console.error.calls.count()).toBe(1);
1015
+ expect(console.error.calls.argsFor(0)[0]).toContain('contentEditable');
1016
});
1017
1018
it('should validate against invalid styles', function() {
@@ -1007,7 +1020,7 @@ describe('ReactDOMComponent', function() {
1020
1021
expect(function() {
1022
ReactDOM.render(<div style={1}></div>, container);
1010
- }).toThrow(
1023
+ }).toThrowError(
1024
'The `style` prop expects a mapping from style properties to values, ' +
1025
'not a string. For example, style={{marginRight: spacing + \'em\'}} ' +
1026
'when using JSX.'
@@ -1023,7 +1036,7 @@ describe('ReactDOMComponent', function() {
1036
1037
expect(function() {
1038
ReactDOM.render(<Animal/>, container);
1026
- }).toThrow(
1039
+ }).toThrowError(
1040
'The `style` prop expects a mapping from style properties to values, ' +
1041
'not a string. For example, style={{marginRight: spacing + \'em\'}} ' +
1042
'when using JSX. This DOM node was rendered by `Animal`.'
@@ -1128,8 +1141,8 @@ describe('ReactDOMComponent', function() {
1141
1142
spyOn(console, 'error');
1143
ReactTestUtils.renderIntoDocument(<div onScroll={function() {}} />);
1131
- expect(console.error.calls.length).toBe(1);
1132
- expect(console.error.argsForCall[0][0]).toBe(
1144
+ expect(console.error.calls.count()).toBe(1);
1145
+ expect(console.error.calls.argsFor(0)[0]).toBe(
1146
'Warning: This browser doesn\'t support the `onScroll` event'
1147
);
1148
});
@@ -1147,7 +1160,7 @@ describe('ReactDOMComponent', function() {
1160
var hackzor = React.createElement('script tag');
1161
expect(
1162
() => ReactTestUtils.renderIntoDocument(hackzor)
1150
- ).toThrow(
1163
+ ).toThrowError(
1164
'Invalid tag: script tag'
1165
);
1166
});
@@ -1157,7 +1170,7 @@ describe('ReactDOMComponent', function() {
1170
var hackzor = React.createElement('div><img /><div');
1171
expect(
1172
() => ReactTestUtils.renderIntoDocument(hackzor)
1160
- ).toThrow(
1173
+ ).toThrowError(
1174
'Invalid tag: div><img /><div'
1175
);
1176
});
@@ -1174,8 +1187,8 @@ describe('ReactDOMComponent', function() {
1187
spyOn(console, 'error');
1188
ReactTestUtils.renderIntoDocument(<div><tr /><tr /></div>);
1189
1177
- expect(console.error.calls.length).toBe(1);
1178
- expect(console.error.argsForCall[0][0]).toBe(
1190
+ expect(console.error.calls.count()).toBe(1);
1191
+ expect(console.error.calls.argsFor(0)[0]).toBe(
1192
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
1193
'<div>. See div > tr.'
1194
);
@@ -1186,8 +1199,8 @@ describe('ReactDOMComponent', function() {
1199
var p = document.createElement('p');
1200
ReactDOM.render(<span><p /></span>, p);
1201
1189
- expect(console.error.calls.length).toBe(1);
1190
- expect(console.error.argsForCall[0][0]).toBe(
1202
+ expect(console.error.calls.count()).toBe(1);
1203
+ expect(console.error.calls.argsFor(0)[0]).toBe(
1204
'Warning: validateDOMNesting(...): <p> cannot appear as a descendant ' +
1205
'of <p>. See p > ... > p.'
1206
);
@@ -1207,13 +1220,13 @@ describe('ReactDOMComponent', function() {
1220
});
1221
ReactTestUtils.renderIntoDocument(<Foo />);
1222
1210
- expect(console.error.calls.length).toBe(2);
1211
- expect(console.error.argsForCall[0][0]).toBe(
1223
+ expect(console.error.calls.count()).toBe(2);
1224
+ expect(console.error.calls.argsFor(0)[0]).toBe(
1225
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
1226
'<table>. See Foo > table > Row > tr. Add a <tbody> to your code to ' +
1227
'match the DOM tree generated by the browser.'
1228
);
1216
- expect(console.error.argsForCall[1][0]).toBe(
1229
+ expect(console.error.calls.argsFor(1)[0]).toBe(
1230
'Warning: validateDOMNesting(...): #text cannot appear as a child ' +
1231
'of <table>. See Foo > table > #text.'
1232
);
@@ -1245,8 +1258,8 @@ describe('ReactDOMComponent', function() {
1258
render: () => <Viz1 />,
1259
});
1260
ReactTestUtils.renderIntoDocument(<App1 />);
1248
- expect(console.error.calls.length).toBe(1);
1249
- expect(console.error.argsForCall[0][0]).toContain(
1261
+ expect(console.error.calls.count()).toBe(1);
1262
+ expect(console.error.calls.argsFor(0)[0]).toContain(
1263
'See Viz1 > table > FancyRow > Row > tr.'
1264
);
1265
@@ -1257,26 +1270,26 @@ describe('ReactDOMComponent', function() {
1270
render: () => <Viz2 />,
1271
});
1272
ReactTestUtils.renderIntoDocument(<App2 />);
1260
- expect(console.error.calls.length).toBe(2);
1261
- expect(console.error.argsForCall[1][0]).toContain(
1273
+ expect(console.error.calls.count()).toBe(2);
1274
+ expect(console.error.calls.argsFor(1)[0]).toContain(
1275
'See Viz2 > FancyTable > Table > table > FancyRow > Row > tr.'
1276
);
1277
1278
ReactTestUtils.renderIntoDocument(<FancyTable><FancyRow /></FancyTable>);
1266
- expect(console.error.calls.length).toBe(3);
1267
- expect(console.error.argsForCall[2][0]).toContain(
1279
+ expect(console.error.calls.count()).toBe(3);
1280
+ expect(console.error.calls.argsFor(2)[0]).toContain(
1281
'See FancyTable > Table > table > FancyRow > Row > tr.'
1282
);
1283
1284
ReactTestUtils.renderIntoDocument(<table><FancyRow /></table>);
1272
- expect(console.error.calls.length).toBe(4);
1273
- expect(console.error.argsForCall[3][0]).toContain(
1285
+ expect(console.error.calls.count()).toBe(4);
1286
+ expect(console.error.calls.argsFor(3)[0]).toContain(
1287
'See table > FancyRow > Row > tr.'
1288
);
1289
1290
ReactTestUtils.renderIntoDocument(<FancyTable><tr /></FancyTable>);
1278
- expect(console.error.calls.length).toBe(5);
1279
- expect(console.error.argsForCall[4][0]).toContain(
1291
+ expect(console.error.calls.count()).toBe(5);
1292
+ expect(console.error.calls.argsFor(4)[0]).toContain(
1293
'See FancyTable > Table > table > tr.'
1294
);
1295
@@ -1286,8 +1299,8 @@ describe('ReactDOMComponent', function() {
1299
},
1300
});
1301
ReactTestUtils.renderIntoDocument(<Link><div><Link /></div></Link>);
1289
- expect(console.error.calls.length).toBe(6);
1290
- expect(console.error.argsForCall[5][0]).toContain(
1302
+ expect(console.error.calls.count()).toBe(6);
1303
+ expect(console.error.calls.argsFor(5)[0]).toContain(
1304
'See Link > a > ... > Link > a.'
1305
);
1306
});
@@ -1295,66 +1308,66 @@ describe('ReactDOMComponent', function() {
1308
it('should warn about incorrect casing on properties (ssr)', function() {
1309
spyOn(console, 'error');
1310
ReactDOMServer.renderToString(React.createElement('input', {type: 'text', tabindex: '1'}));
1298
- expect(console.error.argsForCall.length).toBe(1);
1299
- expect(console.error.argsForCall[0][0]).toContain('tabIndex');
1311
+ expect(console.error.calls.count()).toBe(1);
1312
+ expect(console.error.calls.argsFor(0)[0]).toContain('tabIndex');
1313
});
1314
1315
it('should warn about incorrect casing on event handlers (ssr)', function() {
1316
spyOn(console, 'error');
1317
ReactDOMServer.renderToString(React.createElement('input', {type: 'text', onclick: '1'}));
1318
ReactDOMServer.renderToString(React.createElement('input', {type: 'text', onKeydown: '1'}));
1306
- expect(console.error.argsForCall.length).toBe(2);
1307
- expect(console.error.argsForCall[0][0]).toContain('onClick');
1308
- expect(console.error.argsForCall[1][0]).toContain('onKeyDown');
1319
+ expect(console.error.calls.count()).toBe(2);
1320
+ expect(console.error.calls.argsFor(0)[0]).toContain('onClick');
1321
+ expect(console.error.calls.argsFor(1)[0]).toContain('onKeyDown');
1322
});
1323
1324
it('should warn about incorrect casing on properties', function() {
1325
spyOn(console, 'error');
1326
ReactTestUtils.renderIntoDocument(React.createElement('input', {type: 'text', tabindex: '1'}));
1314
- expect(console.error.argsForCall.length).toBe(1);
1315
- expect(console.error.argsForCall[0][0]).toContain('tabIndex');
1327
+ expect(console.error.calls.count(0)).toBe(1);
1328
+ expect(console.error.calls.argsFor(0)[0]).toContain('tabIndex');
1329
});
1330
1331
it('should warn about incorrect casing on event handlers', function() {
1332
spyOn(console, 'error');
1333
ReactTestUtils.renderIntoDocument(React.createElement('input', {type: 'text', onclick: '1'}));
1334
ReactTestUtils.renderIntoDocument(React.createElement('input', {type: 'text', onKeydown: '1'}));
1322
- expect(console.error.argsForCall.length).toBe(2);
1323
- expect(console.error.argsForCall[0][0]).toContain('onClick');
1324
- expect(console.error.argsForCall[1][0]).toContain('onKeyDown');
1335
+ expect(console.error.calls.count(0)).toBe(2);
1336
+ expect(console.error.calls.argsFor(0)[0]).toContain('onClick');
1337
+ expect(console.error.calls.argsFor(1)[0]).toContain('onKeyDown');
1338
});
1339
1340
it('should warn about class', function() {
1341
spyOn(console, 'error');
1342
ReactDOMServer.renderToString(React.createElement('div', {class: 'muffins'}));
1330
- expect(console.error.argsForCall.length).toBe(1);
1331
- expect(console.error.argsForCall[0][0]).toContain('className');
1343
+ expect(console.error.calls.count()).toBe(1);
1344
+ expect(console.error.calls.argsFor(0)[0]).toContain('className');
1345
});
1346
1347
it('should warn about props that are no longer supported', function() {
1348
spyOn(console, 'error');
1349
ReactTestUtils.renderIntoDocument(<div />);
1337
- expect(console.error.argsForCall.length).toBe(0);
1350
+ expect(console.error.calls.count()).toBe(0);
1351
1352
ReactTestUtils.renderIntoDocument(<div onFocusIn={() => {}} />);
1340
- expect(console.error.argsForCall.length).toBe(1);
1353
+ expect(console.error.calls.count()).toBe(1);
1354
1355
ReactTestUtils.renderIntoDocument(<div onFocusOut={() => {}} />);
1343
- expect(console.error.argsForCall.length).toBe(2);
1356
+ expect(console.error.calls.count()).toBe(2);
1357
});
1358
1359
it('gives source code refs for unknown prop warning', function() {
1360
spyOn(console, 'error');
1361
ReactDOMServer.renderToString(<div class="paladin"/>);
1362
ReactDOMServer.renderToString(<input type="text" onclick="1"/>);
1350
- expect(console.error.argsForCall.length).toBe(2);
1363
+ expect(console.error.calls.count()).toBe(2);
1364
expect(
1352
- normalizeCodeLocInfo(console.error.argsForCall[0][0])
1365
+ normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])
1366
).toBe(
1367
'Warning: Unknown DOM property class. Did you mean className?\n in div (at **)'
1368
);
1369
expect(
1357
- normalizeCodeLocInfo(console.error.argsForCall[1][0])
1370
+ normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])
1371
).toBe(
1372
'Warning: Unknown event handler property onclick. Did you mean ' +
1373
'`onClick`?\n in input (at **)'
@@ -1366,12 +1379,12 @@ describe('ReactDOMComponent', function() {
1379
var container = document.createElement('div');
1380
1381
ReactDOMServer.renderToString(<div className="paladin" />, container);
1369
- expect(console.error.argsForCall.length).toBe(0);
1382
+ expect(console.error.calls.count()).toBe(0);
1383
1384
ReactDOMServer.renderToString(<div class="paladin" />, container);
1372
- expect(console.error.argsForCall.length).toBe(1);
1385
+ expect(console.error.calls.count()).toBe(1);
1386
expect(
1374
- normalizeCodeLocInfo(console.error.argsForCall[0][0])
1387
+ normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])
1388
).toBe(
1389
'Warning: Unknown DOM property class. Did you mean className?\n in div (at **)'
1390
);
@@ -1391,14 +1404,14 @@ describe('ReactDOMComponent', function() {
1404
</div>
1405
);
1406
1394
- expect(console.error.argsForCall.length).toBe(2);
1407
+ expect(console.error.calls.count()).toBe(2);
1408
1396
- expect(console.error.argsForCall[0][0]).toContain('className');
1397
- var matches = console.error.argsForCall[0][0].match(/.*\(.*:(\d+)\).*/);
1409
+ expect(console.error.calls.argsFor(0)[0]).toContain('className');
1410
+ var matches = console.error.calls.argsFor(0)[0].match(/.*\(.*:(\d+)\).*/);
1411
var previousLine = matches[1];
1412
1400
- expect(console.error.argsForCall[1][0]).toContain('onClick');
1401
- matches = console.error.argsForCall[1][0].match(/.*\(.*:(\d+)\).*/);
1413
+ expect(console.error.calls.argsFor(1)[0]).toContain('onClick');
1414
+ matches = console.error.calls.argsFor(1)[0].match(/.*\(.*:(\d+)\).*/);
1415
var currentLine = matches[1];
1416
1417
//verify line number has a proper relative difference,
@@ -1442,14 +1455,14 @@ describe('ReactDOMComponent', function() {
1455
1456
ReactDOMServer.renderToString(<Parent />, container);
1457
1445
- expect(console.error.argsForCall.length).toBe(2);
1458
+ expect(console.error.calls.count()).toBe(2);
1459
1447
- expect(console.error.argsForCall[0][0]).toContain('className');
1448
- var matches = console.error.argsForCall[0][0].match(/.*\(.*:(\d+)\).*/);
1460
+ expect(console.error.calls.argsFor(0)[0]).toContain('className');
1461
+ var matches = console.error.calls.argsFor(0)[0].match(/.*\(.*:(\d+)\).*/);
1462
var previousLine = matches[1];
1463
1451
- expect(console.error.argsForCall[1][0]).toContain('onClick');
1452
- matches = console.error.argsForCall[1][0].match(/.*\(.*:(\d+)\).*/);
1464
+ expect(console.error.calls.argsFor(1)[0]).toContain('onClick');
1465
+ matches = console.error.calls.argsFor(1)[0].match(/.*\(.*:(\d+)\).*/);
1466
var currentLine = matches[1];
1467
1468
//verify line number has a proper relative difference,
src/renderers/shared/stack/event/__tests__/EventPluginHub-test.js
+1
-1
@@ -29,7 +29,7 @@ describe('EventPluginHub', function() {
29
it('should prevent non-function listeners', function() {
30
expect(function() {
31
EventPluginHub.putListener(1, 'onClick', 'not a function');
32
- }).toThrow(
32
+ }).toThrowError(
33
'Expected onClick listener to be a function, instead got type string'
34
);
35
});
src/renderers/shared/stack/event/__tests__/EventPluginRegistry-test.js
+6
-6
@@ -95,7 +95,7 @@ describe('EventPluginRegistry', function() {
95
EventPluginRegistry.injectEventPluginsByName({
96
bad: BadPlugin,
97
});
98
- }).toThrow(
98
+ }).toThrowError(
99
'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
100
'method, but `bad` does not.'
101
);
@@ -112,7 +112,7 @@ describe('EventPluginRegistry', function() {
112
one: OnePlugin,
113
random: RandomPlugin,
114
});
115
- }).toThrow(
115
+ }).toThrowError(
116
'EventPluginRegistry: Cannot inject event plugins that do not exist ' +
117
'in the plugin ordering, `random`.'
118
);
@@ -125,7 +125,7 @@ describe('EventPluginRegistry', function() {
125
126
expect(function() {
127
EventPluginRegistry.injectEventPluginOrder(pluginOrdering);
128
- }).toThrow(
128
+ }).toThrowError(
129
'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
130
'once. You are likely trying to load more than one copy of React.'
131
);
@@ -139,7 +139,7 @@ describe('EventPluginRegistry', function() {
139
140
expect(function() {
141
EventPluginRegistry.injectEventPluginsByName({same: TwoPlugin});
142
- }).toThrow(
142
+ }).toThrowError(
143
'EventPluginRegistry: Cannot inject two different event plugins using ' +
144
'the same name, `same`.'
145
);
@@ -203,7 +203,7 @@ describe('EventPluginRegistry', function() {
203
204
expect(function() {
205
EventPluginRegistry.injectEventPluginOrder(['one', 'two']);
206
- }).toThrow(
206
+ }).toThrowError(
207
'EventPluginHub: More than one plugin attempted to publish the same ' +
208
'registration name, `onPhotoCapture`.'
209
);
@@ -220,7 +220,7 @@ describe('EventPluginRegistry', function() {
220
221
expect(function() {
222
EventPluginRegistry.injectEventPluginOrder(['one']);
223
- }).toThrow(
223
+ }).toThrowError(
224
'EventPluginRegistry: Failed to publish event `badEvent` for plugin ' +
225
'`one`.'
226
);
src/renderers/shared/stack/reconciler/__tests__/ReactComponent-test.js
+6
-6
@@ -27,13 +27,13 @@ describe('ReactComponent', function() {
27
// jQuery objects are basically arrays; people often pass them in by mistake
28
expect(function() {
29
ReactDOM.render(<div></div>, [container]);
30
- }).toThrow(
30
+ }).toThrowError(
31
'_registerComponent(...): Target container is not a DOM element.'
32
);
33
34
expect(function() {
35
ReactDOM.render(<div></div>, null);
36
- }).toThrow(
36
+ }).toThrowError(
37
'_registerComponent(...): Target container is not a DOM element.'
38
);
39
});
@@ -269,25 +269,25 @@ describe('ReactComponent', function() {
269
spyOn(console, 'error');
270
271
var X = undefined;
272
- expect(() => ReactTestUtils.renderIntoDocument(<X />)).toThrow(
272
+ expect(() => ReactTestUtils.renderIntoDocument(<X />)).toThrowError(
273
'Element type is invalid: expected a string (for built-in components) ' +
274
'or a class/function (for composite components) but got: undefined.'
275
);
276
277
var Y = null;
278
- expect(() => ReactTestUtils.renderIntoDocument(<Y />)).toThrow(
278
+ expect(() => ReactTestUtils.renderIntoDocument(<Y />)).toThrowError(
279
'Element type is invalid: expected a string (for built-in components) ' +
280
'or a class/function (for composite components) but got: null.'
281
);
282
283
var Z = {};
284
- expect(() => ReactTestUtils.renderIntoDocument(<Z />)).toThrow(
284
+ expect(() => ReactTestUtils.renderIntoDocument(<Z />)).toThrowError(
285
'Element type is invalid: expected a string (for built-in components) ' +
286
'or a class/function (for composite components) but got: object.'
287
);
288
289
// One warning for each element creation
290
- expect(console.error.calls.length).toBe(3);
290
+ expect(console.error.calls.count()).toBe(3);
291
});
292
293
});
src/renderers/shared/stack/reconciler/__tests__/ReactComponentLifeCycle-test.js
+8
-8
@@ -224,8 +224,8 @@ describe('ReactComponentLifeCycle', function() {
224
},
225
});
226
ReactTestUtils.renderIntoDocument(<StatefulComponent />);
227
- expect(console.error.calls.length).toBe(1);
228
- expect(console.error.argsForCall[0][0]).toBe(
227
+ expect(console.error.calls.count()).toBe(1);
228
+ expect(console.error.calls.argsFor(0)[0]).toBe(
229
'Warning: setState(...): Can only update a mounted or ' +
230
'mounting component. This usually means you called setState() on an ' +
231
'unmounted component. This is a no-op. Please check the code for the ' +
@@ -253,8 +253,8 @@ describe('ReactComponentLifeCycle', function() {
253
var instance = ReactTestUtils.renderIntoDocument(element);
254
expect(instance.isMounted()).toBeTruthy();
255
256
- expect(console.error.argsForCall.length).toBe(1);
257
- expect(console.error.argsForCall[0][0]).toContain(
256
+ expect(console.error.calls.count()).toBe(1);
257
+ expect(console.error.calls.argsFor(0)[0]).toContain(
258
'Component is accessing isMounted inside its render()'
259
);
260
});
@@ -279,8 +279,8 @@ describe('ReactComponentLifeCycle', function() {
279
var instance = ReactTestUtils.renderIntoDocument(element);
280
expect(instance.isMounted()).toBeTruthy();
281
282
- expect(console.error.argsForCall.length).toBe(1);
283
- expect(console.error.argsForCall[0][0]).toContain(
282
+ expect(console.error.calls.count()).toBe(1);
283
+ expect(console.error.calls.argsFor(0)[0]).toContain(
284
'Component is accessing isMounted inside its render()'
285
);
286
});
@@ -320,8 +320,8 @@ describe('ReactComponentLifeCycle', function() {
320
});
321
322
ReactTestUtils.renderIntoDocument(<Component />);
323
- expect(console.error.argsForCall.length).toBe(1);
324
- expect(console.error.argsForCall[0][0]).toContain(
323
+ expect(console.error.calls.count()).toBe(1);
324
+ expect(console.error.calls.argsFor(0)[0]).toContain(
325
'Component is accessing findDOMNode inside its render()'
326
);
327
});
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js
+20
-20
@@ -199,11 +199,11 @@ describe('ReactCompositeComponent', function() {
199
mountedInstance.methodAutoBound();
200
}).not.toThrow();
201
202
- expect(console.error.argsForCall.length).toBe(1);
202
+ expect(console.error.calls.count()).toBe(1);
203
var explicitlyBound = mountedInstance.methodToBeExplicitlyBound.bind(
204
mountedInstance
205
);
206
- expect(console.error.argsForCall.length).toBe(2);
206
+ expect(console.error.calls.count()).toBe(2);
207
var autoBound = mountedInstance.methodAutoBound;
208
209
var context = {};
@@ -289,13 +289,13 @@ describe('ReactCompositeComponent', function() {
289
instance = ReactDOM.render(instance, container);
290
instance.forceUpdate();
291
292
- expect(console.error.calls.length).toBe(0);
292
+ expect(console.error.calls.count()).toBe(0);
293
294
ReactDOM.unmountComponentAtNode(container);
295
296
instance.forceUpdate();
297
- expect(console.error.calls.length).toBe(1);
298
- expect(console.error.argsForCall[0][0]).toBe(
297
+ expect(console.error.calls.count()).toBe(1);
298
+ expect(console.error.calls.argsFor(0)[0]).toBe(
299
'Warning: forceUpdate(...): Can only update a mounted or ' +
300
'mounting component. This usually means you called forceUpdate() on an ' +
301
'unmounted component. This is a no-op. Please check the code for the ' +
@@ -330,7 +330,7 @@ describe('ReactCompositeComponent', function() {
330
331
instance.setState({value: 1});
332
333
- expect(console.error.calls.length).toBe(0);
333
+ expect(console.error.calls.count()).toBe(0);
334
335
expect(renders).toBe(2);
336
@@ -339,8 +339,8 @@ describe('ReactCompositeComponent', function() {
339
340
expect(renders).toBe(2);
341
342
- expect(console.error.calls.length).toBe(1);
343
- expect(console.error.argsForCall[0][0]).toBe(
342
+ expect(console.error.calls.count()).toBe(1);
343
+ expect(console.error.calls.argsFor(0)[0]).toBe(
344
'Warning: setState(...): Can only update a mounted or ' +
345
'mounting component. This usually means you called setState() on an ' +
346
'unmounted component. This is a no-op. Please check the code for the ' +
@@ -399,12 +399,12 @@ describe('ReactCompositeComponent', function() {
399
},
400
});
401
402
- expect(console.error.calls.length).toBe(0);
402
+ expect(console.error.calls.count()).toBe(0);
403
404
var instance = ReactDOM.render(<Component />, container);
405
406
- expect(console.error.calls.length).toBe(1);
407
- expect(console.error.argsForCall[0][0]).toBe(
406
+ expect(console.error.calls.count()).toBe(1);
407
+ expect(console.error.calls.argsFor(0)[0]).toBe(
408
'Warning: setState(...): Cannot update during an existing state ' +
409
'transition (such as within `render` or another component\'s ' +
410
'constructor). Render methods should be a pure function of props and ' +
@@ -522,8 +522,8 @@ describe('ReactCompositeComponent', function() {
522
var instance = ReactTestUtils.renderIntoDocument(<Component />);
523
instance.setState({bogus: true});
524
525
- expect(console.error.argsForCall.length).toBe(1);
526
- expect(console.error.argsForCall[0][0]).toBe(
525
+ expect(console.error.calls.count()).toBe(1);
526
+ expect(console.error.calls.argsFor(0)[0]).toBe(
527
'Warning: Component.shouldComponentUpdate(): Returned undefined instead of a ' +
528
'boolean value. Make sure to return true or false.'
529
);
@@ -543,8 +543,8 @@ describe('ReactCompositeComponent', function() {
543
544
ReactTestUtils.renderIntoDocument(<Component />);
545
546
- expect(console.error.calls.length).toBe(1);
547
- expect(console.error.argsForCall[0][0]).toBe(
546
+ expect(console.error.calls.count()).toBe(1);
547
+ expect(console.error.calls.argsFor(0)[0]).toBe(
548
'Warning: Component has a method called ' +
549
'componentDidUnmount(). But there is no such lifecycle method. ' +
550
'Did you mean componentWillUnmount()?'
@@ -1053,8 +1053,8 @@ describe('ReactCompositeComponent', function() {
1053
});
1054
1055
ReactTestUtils.renderIntoDocument(<Outer />);
1056
- expect(console.error.argsForCall.length).toBe(1);
1057
- expect(console.error.argsForCall[0][0]).toBe(
1056
+ expect(console.error.calls.count()).toBe(1);
1057
+ expect(console.error.calls.argsFor(0)[0]).toBe(
1058
'Warning: _renderNewRootComponent(): Render methods should ' +
1059
'be a pure function of props and state; triggering nested component ' +
1060
'updates from render is not allowed. If necessary, trigger nested ' +
@@ -1291,12 +1291,12 @@ describe('ReactCompositeComponent', function() {
1291
}
1292
}
1293
1294
- expect(console.error.calls.length).toBe(0);
1294
+ expect(console.error.calls.count()).toBe(0);
1295
1296
ReactDOM.render(<Foo idx="qwe" />, container);
1297
1298
- expect(console.error.calls.length).toBe(1);
1299
- expect(console.error.argsForCall[0][0]).toContain(
1298
+ expect(console.error.calls.count()).toBe(1);
1299
+ expect(console.error.calls.argsFor(0)[0]).toContain(
1300
'Foo(...): When calling super() in `Foo`, make sure to pass ' +
1301
'up the same props that your component\'s constructor was passed.'
1302
);
src/renderers/shared/stack/reconciler/__tests__/ReactEmptyComponent-test.js
+24
-24
@@ -78,7 +78,7 @@ describe('ReactEmptyComponent', function() {
78
});
79
expect(function() {
80
ReactTestUtils.renderIntoDocument(<Component />);
81
- }).toThrow(
81
+ }).toThrowError(
82
'Component.render(): A valid React element (or null) must be returned. You may ' +
83
'have returned undefined, an array or some other invalid object.'
84
);
@@ -99,11 +99,11 @@ describe('ReactEmptyComponent', function() {
99
ReactTestUtils.renderIntoDocument(instance1);
100
ReactTestUtils.renderIntoDocument(instance2);
101
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);
102
+ expect(log.calls.count()).toBe(4);
103
+ expect(log.calls.argsFor(0)[0]).toBe(null);
104
+ expect(log.calls.argsFor(1)[0].tagName).toBe('DIV');
105
+ expect(log.calls.argsFor(2)[0].tagName).toBe('DIV');
106
+ expect(log.calls.argsFor(3)[0]).toBe(null);
107
});
108
109
it('should be able to switch in a list of children', () => {
@@ -121,13 +121,13 @@ describe('ReactEmptyComponent', function() {
121
</div>
122
);
123
124
- expect(log.argsForCall.length).toBe(6);
125
- expect(log.argsForCall[0][0]).toBe(null);
126
- expect(log.argsForCall[1][0]).toBe(null);
127
- expect(log.argsForCall[2][0]).toBe(null);
128
- expect(log.argsForCall[3][0].tagName).toBe('DIV');
129
- expect(log.argsForCall[4][0].tagName).toBe('DIV');
130
- expect(log.argsForCall[5][0].tagName).toBe('DIV');
124
+ expect(log.calls.count()).toBe(6);
125
+ expect(log.calls.argsFor(0)[0]).toBe(null);
126
+ expect(log.calls.argsFor(1)[0]).toBe(null);
127
+ expect(log.calls.argsFor(2)[0]).toBe(null);
128
+ expect(log.calls.argsFor(3)[0].tagName).toBe('DIV');
129
+ expect(log.calls.argsFor(4)[0].tagName).toBe('DIV');
130
+ expect(log.calls.argsFor(5)[0].tagName).toBe('DIV');
131
});
132
133
it('should distinguish between a script placeholder and an actual script tag',
@@ -150,11 +150,11 @@ describe('ReactEmptyComponent', function() {
150
ReactTestUtils.renderIntoDocument(instance2);
151
}).not.toThrow();
152
153
- expect(log.argsForCall.length).toBe(4);
154
- expect(log.argsForCall[0][0]).toBe(null);
155
- expect(log.argsForCall[1][0].tagName).toBe('SCRIPT');
156
- expect(log.argsForCall[2][0].tagName).toBe('SCRIPT');
157
- expect(log.argsForCall[3][0]).toBe(null);
153
+ expect(log.calls.count()).toBe(4);
154
+ expect(log.calls.argsFor(0)[0]).toBe(null);
155
+ expect(log.calls.argsFor(1)[0].tagName).toBe('SCRIPT');
156
+ expect(log.calls.argsFor(2)[0].tagName).toBe('SCRIPT');
157
+ expect(log.calls.argsFor(3)[0]).toBe(null);
158
}
159
);
160
@@ -191,11 +191,11 @@ describe('ReactEmptyComponent', function() {
191
ReactTestUtils.renderIntoDocument(instance2);
192
}).not.toThrow();
193
194
- expect(log.argsForCall.length).toBe(4);
195
- expect(log.argsForCall[0][0].tagName).toBe('DIV');
196
- expect(log.argsForCall[1][0]).toBe(null);
197
- expect(log.argsForCall[2][0]).toBe(null);
198
- expect(log.argsForCall[3][0].tagName).toBe('DIV');
194
+ expect(log.calls.count()).toBe(4);
195
+ expect(log.calls.argsFor(0)[0].tagName).toBe('DIV');
196
+ expect(log.calls.argsFor(1)[0]).toBe(null);
197
+ expect(log.calls.argsFor(2)[0]).toBe(null);
198
+ expect(log.calls.argsFor(3)[0].tagName).toBe('DIV');
199
}
200
);
201
@@ -247,7 +247,7 @@ describe('ReactEmptyComponent', function() {
247
var div = document.createElement('div');
248
expect(function() {
249
ReactDOM.render(null, div);
250
- }).toThrow(
250
+ }).toThrowError(
251
'ReactDOM.render(): Invalid component element.'
252
);
253
});
src/renderers/shared/stack/reconciler/__tests__/ReactMockedComponent-test.js
+1
-1
@@ -32,7 +32,7 @@ describe('ReactMockedComponent', function() {
32
it('should allow an implicitly mocked component to be rendered without warnings', () => {
33
spyOn(console, 'error');
34
ReactTestUtils.renderIntoDocument(<AutoMockedComponent />);
35
- expect(console.error.calls.length).toBe(0);
35
+ expect(console.error.calls.count()).toBe(0);
36
});
37
38
it('should allow an implicitly mocked component to be updated', () => {
src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildReconcile-test.js
+1
-1
@@ -273,7 +273,7 @@ describe('ReactMultiChildReconcile', function() {
273
statusDisplays = parentInstance.getStatusDisplays();
274
expect(statusDisplays.jcw).toBeTruthy();
275
expect(statusDisplays.jcw.getInternalState())
276
- .toNotBe(startingInternalState);
276
+ .not.toBe(startingInternalState);
277
});
278
279
it('should create unique identity', function() {
src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildText-test.js
+3
-3
@@ -183,8 +183,8 @@ describe('ReactMultiChildText', function() {
183
[true, <div>{1.2}{''}{<div />}{'foo'}</div>, true, 1.2], [<div />, '1.2'],
184
['', 'foo', <div>{true}{<div />}{1.2}{''}</div>, 'foo'], ['', 'foo', <div />, 'foo'],
185
]);
186
- expect(console.error.calls.length).toBe(1);
187
- expect(console.error.argsForCall[0][0]).toContain(
186
+ expect(console.error.calls.count()).toBe(1);
187
+ expect(console.error.calls.argsFor(0)[0]).toContain(
188
'Warning: Each child in an array or iterator should have a unique "key" prop.'
189
);
190
});
@@ -244,6 +244,6 @@ describe('ReactMultiChildText', function() {
244
expect(childNodes[5]).toBe(alpha3);
245
246
// Using Maps as children gives a single warning
247
- expect(console.error.calls.length).toBe(1);
247
+ expect(console.error.calls.count()).toBe(1);
248
});
249
});
src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js
+12
-12
@@ -106,8 +106,8 @@ describe('ReactStatelessComponent', function() {
106
expect(function() {
107
ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
108
}).toThrow();
109
- expect(console.error.calls.length).toBe(1);
110
- expect(console.error.argsForCall[0][0]).toContain(
109
+ expect(console.error.calls.count()).toBe(1);
110
+ expect(console.error.calls.argsFor(0)[0]).toContain(
111
'NotAComponent(...): A valid React element (or null) must be returned. ' +
112
'You may have returned undefined, an array or some other invalid object.'
113
);
@@ -120,7 +120,7 @@ describe('ReactStatelessComponent', function() {
120
121
expect(function() {
122
ReactTestUtils.renderIntoDocument(<Child test="test" />);
123
- }).toThrow(
123
+ }).toThrowError(
124
'Stateless function components cannot have refs.'
125
);
126
});
@@ -136,8 +136,8 @@ describe('ReactStatelessComponent', function() {
136
});
137
ReactTestUtils.renderIntoDocument(<Parent/>);
138
139
- expect(console.error.argsForCall.length).toBe(1);
140
- expect(console.error.argsForCall[0][0]).toContain(
139
+ expect(console.error.calls.count()).toBe(1);
140
+ expect(console.error.calls.argsFor(0)[0]).toContain(
141
'Stateless function components cannot be given refs ' +
142
'(See ref "stateless" in StatelessComponent created by Parent). ' +
143
'Attempts to access this ref will fail.'
@@ -160,9 +160,9 @@ describe('ReactStatelessComponent', function() {
160
161
spyOn(console, 'error');
162
ReactTestUtils.renderIntoDocument(<Child />);
163
- expect(console.error.argsForCall.length).toBe(1);
164
- expect(console.error.argsForCall[0][0]).toContain('a unique "key" prop');
165
- expect(console.error.argsForCall[0][0]).toContain('Child');
163
+ expect(console.error.calls.count()).toBe(1);
164
+ expect(console.error.calls.argsFor(0)[0]).toContain('a unique "key" prop');
165
+ expect(console.error.calls.argsFor(0)[0]).toContain('Child');
166
});
167
168
it('should support default props and prop types', function() {
@@ -174,9 +174,9 @@ describe('ReactStatelessComponent', function() {
174
175
spyOn(console, 'error');
176
ReactTestUtils.renderIntoDocument(<Child />);
177
- expect(console.error.argsForCall.length).toBe(1);
177
+ expect(console.error.calls.count()).toBe(1);
178
expect(
179
- console.error.argsForCall[0][0].replace(/\(at .+?:\d+\)/g, '(at **)')
179
+ console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)')
180
).toBe(
181
'Warning: Failed prop type: Invalid prop `test` of type `number` ' +
182
'supplied to `Child`, expected `string`.\n' +
@@ -239,8 +239,8 @@ describe('ReactStatelessComponent', function() {
239
expect(function() {
240
ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
241
}).toThrow(); // has no method 'render'
242
- expect(console.error.calls.length).toBe(1);
243
- expect(console.error.argsForCall[0][0]).toContain(
242
+ expect(console.error.calls.count()).toBe(1);
243
+ expect(console.error.calls.argsFor(0)[0]).toContain(
244
'NotAComponent(...): A valid React element (or null) must be returned. You may ' +
245
'have returned undefined, an array or some other invalid object.'
246
);
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
+7
-7
@@ -495,7 +495,7 @@ describe('ReactUpdates', function() {
495
496
it('should share reconcile transaction across different roots', function() {
497
var ReconcileTransaction = ReactUpdates.ReactReconcileTransaction;
498
- spyOn(ReconcileTransaction, 'getPooled').andCallThrough();
498
+ spyOn(ReconcileTransaction, 'getPooled').and.callThrough();
499
500
var Component = React.createClass({
501
render: function() {
@@ -511,7 +511,7 @@ describe('ReactUpdates', function() {
511
ReactDOM.render(<Component text="A1" />, containerA);
512
ReactDOM.render(<Component text="B1" />, containerB);
513
});
514
- expect(ReconcileTransaction.getPooled.calls.length).toBe(2);
514
+ expect(ReconcileTransaction.getPooled.calls.count()).toBe(2);
515
516
// ...but updates are! Here only one more transaction is used, which means
517
// we only have to initialize and close the wrappers once.
@@ -519,7 +519,7 @@ describe('ReactUpdates', function() {
519
ReactDOM.render(<Component text="A2" />, containerA);
520
ReactDOM.render(<Component text="B2" />, containerB);
521
});
522
- expect(ReconcileTransaction.getPooled.calls.length).toBe(3);
522
+ expect(ReconcileTransaction.getPooled.calls.count()).toBe(3);
523
});
524
525
it('should queue mount-ready handlers across different roots', function() {
@@ -929,10 +929,10 @@ describe('ReactUpdates', function() {
929
930
ReactDOM.render(<Foo />, container);
931
932
- expect(console.time.argsForCall.length).toBe(1);
933
- expect(console.time.argsForCall[0][0]).toBe('React update: Foo');
934
- expect(console.timeEnd.argsForCall.length).toBe(1);
935
- expect(console.timeEnd.argsForCall[0][0]).toBe('React update: Foo');
932
+ expect(console.time.calls.count()).toBe(1);
933
+ expect(console.time.calls.argsFor(0)[0]).toBe('React update: Foo');
934
+ expect(console.timeEnd.calls.count()).toBe(1);
935
+ expect(console.timeEnd.calls.argsFor(0)[0]).toBe('React update: Foo');
936
} finally {
937
ReactFeatureFlags.logTopLevelRenders = false;
938
}
src/shared/utils/__tests__/PooledClass-test.js
+1
-1
@@ -110,7 +110,7 @@ describe('Pooled class', function() {
110
PoolableClass.getPooled();
111
expect(function() {
112
PoolableClass.release(randomInstance);
113
- }).toThrow(
113
+ }).toThrowError(
114
'Trying to release an instance into a pool of a different type.'
115
);
116
}
src/shared/utils/__tests__/Transaction-test.js
+1
-1
@@ -236,7 +236,7 @@ describe('Transaction', function() {
236
var transaction = new TestTransaction();
237
expect(function() {
238
transaction.perform(function() {});
239
- }).toThrow(exceptionMsg);
239
+ }).toThrowError(exceptionMsg);
240
expect(transaction.isInTransaction()).toBe(false);
241
});
242
src/shared/utils/__tests__/accumulateInto-test.js
+1
-1
@@ -25,7 +25,7 @@ describe('accumulateInto', function() {
25
it('throws if the second item is null', function() {
26
expect(function() {
27
accumulateInto([], null);
28
- }).toThrow(
28
+ }).toThrowError(
29
'accumulateInto(...): Accumulated items must not be null or undefined.'
30
);
31
});
src/shared/utils/__tests__/traverseAllChildren-test.js
+25
-25
@@ -29,7 +29,7 @@ describe('traverseAllChildren', function() {
29
it('should support identity for simple', function() {
30
var traverseContext = [];
31
var traverseFn =
32
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
32
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
33
context.push(true);
34
});
35
@@ -49,7 +49,7 @@ describe('traverseAllChildren', function() {
49
it('should treat single arrayless child as being in array', function() {
50
var traverseContext = [];
51
var traverseFn =
52
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
52
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
53
context.push(true);
54
});
55
@@ -68,7 +68,7 @@ describe('traverseAllChildren', function() {
68
spyOn(console, 'error');
69
var traverseContext = [];
70
var traverseFn =
71
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
71
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
72
context.push(true);
73
});
74
@@ -81,8 +81,8 @@ describe('traverseAllChildren', function() {
81
'.0'
82
);
83
expect(traverseContext.length).toEqual(1);
84
- expect(console.error.calls.length).toBe(1);
85
- expect(console.error.argsForCall[0][0]).toContain(
84
+ expect(console.error.calls.count()).toBe(1);
85
+ expect(console.error.calls.ForCall(0)[0]).toContain(
86
'Warning: Each child in an array or iterator should have a unique "key" prop.'
87
);
88
});
@@ -96,7 +96,7 @@ describe('traverseAllChildren', function() {
96
97
var traverseContext = [];
98
var traverseFn =
99
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
99
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
100
context.push(true);
101
});
102
@@ -137,7 +137,7 @@ describe('traverseAllChildren', function() {
137
138
var traverseContext = [];
139
var traverseFn =
140
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
140
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
141
context.push(true);
142
});
143
@@ -157,7 +157,7 @@ describe('traverseAllChildren', function() {
157
158
traverseAllChildren(instance.props.children, traverseFn, traverseContext);
159
160
- expect(traverseFn.calls.length).toBe(9);
160
+ expect(traverseFn.calls.count()).toBe(9);
161
expect(traverseContext.length).toEqual(9);
162
163
expect(traverseFn).toHaveBeenCalledWith(
@@ -205,7 +205,7 @@ describe('traverseAllChildren', function() {
205
206
var traverseContext = [];
207
var traverseFn =
208
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
208
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
209
context.push(true);
210
});
211
@@ -222,7 +222,7 @@ describe('traverseAllChildren', function() {
222
);
223
224
traverseAllChildren(instance.props.children, traverseFn, traverseContext);
225
- expect(traverseFn.calls.length).toBe(4);
225
+ expect(traverseFn.calls.count()).toBe(4);
226
expect(traverseContext.length).toEqual(4);
227
expect(traverseFn).toHaveBeenCalledWith(
228
traverseContext,
@@ -254,7 +254,7 @@ describe('traverseAllChildren', function() {
254
var oneForceKey = <div key="keyOne" />;
255
var traverseContext = [];
256
var traverseFn =
257
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
257
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
258
context.push(true);
259
});
260
@@ -298,7 +298,7 @@ describe('traverseAllChildren', function() {
298
299
var traverseContext = [];
300
var traverseFn =
301
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
301
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
302
context.push(kid);
303
});
304
@@ -309,7 +309,7 @@ describe('traverseAllChildren', function() {
309
);
310
311
traverseAllChildren(instance.props.children, traverseFn, traverseContext);
312
- expect(traverseFn.calls.length).toBe(3);
312
+ expect(traverseFn.calls.count()).toBe(3);
313
314
expect(traverseFn).toHaveBeenCalledWith(
315
traverseContext,
@@ -327,8 +327,8 @@ describe('traverseAllChildren', function() {
327
'.2'
328
);
329
330
- expect(console.error.calls.length).toBe(1);
331
- expect(console.error.argsForCall[0][0]).toContain(
330
+ expect(console.error.calls.count()).toBe(1);
331
+ expect(console.error.calls.ForCall(0)[0]).toContain(
332
'Warning: Each child in an array or iterator should have a unique "key" prop.'
333
);
334
});
@@ -351,7 +351,7 @@ describe('traverseAllChildren', function() {
351
352
var traverseContext = [];
353
var traverseFn =
354
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
354
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
355
context.push(kid);
356
});
357
@@ -362,7 +362,7 @@ describe('traverseAllChildren', function() {
362
);
363
364
traverseAllChildren(instance.props.children, traverseFn, traverseContext);
365
- expect(traverseFn.calls.length).toBe(3);
365
+ expect(traverseFn.calls.count()).toBe(3);
366
367
expect(traverseFn).toHaveBeenCalledWith(
368
traverseContext,
@@ -402,7 +402,7 @@ describe('traverseAllChildren', function() {
402
403
var traverseContext = [];
404
var traverseFn =
405
- jasmine.createSpy().andCallFake(function(context, kid, key, index) {
405
+ jasmine.createSpy().and.callFake(function(context, kid, key, index) {
406
context.push(kid);
407
});
408
@@ -413,7 +413,7 @@ describe('traverseAllChildren', function() {
413
);
414
415
traverseAllChildren(instance.props.children, traverseFn, traverseContext);
416
- expect(traverseFn.calls.length).toBe(3);
416
+ expect(traverseFn.calls.count()).toBe(3);
417
418
expect(traverseFn).toHaveBeenCalledWith(
419
traverseContext,
@@ -431,8 +431,8 @@ describe('traverseAllChildren', function() {
431
'.$#3:0'
432
);
433
434
- expect(console.error.argsForCall.length).toBe(1);
435
- expect(console.error.argsForCall[0][0]).toContain(
434
+ expect(console.error.calls.count()).toBe(1);
435
+ expect(console.error.calls.argsFor(0)[0]).toContain(
436
'Warning: Using Maps as children is not yet fully supported. It is an ' +
437
'experimental feature that might be removed. Convert it to a sequence ' +
438
'/ iterable of keyed ReactElements instead.'
@@ -458,7 +458,7 @@ describe('traverseAllChildren', function() {
458
var traverseFn = jasmine.createSpy();
459
460
traverseAllChildren(instance.props.children, traverseFn, null);
461
- expect(traverseFn.calls.length).toBe(3);
461
+ expect(traverseFn.calls.count()).toBe(3);
462
463
expect(traverseFn).toHaveBeenCalledWith(
464
null,
@@ -496,7 +496,7 @@ describe('traverseAllChildren', function() {
496
var traverseFn = jasmine.createSpy();
497
498
traverseAllChildren(instance.props.children, traverseFn, null);
499
- expect(traverseFn.calls.length).toBe(2);
499
+ expect(traverseFn.calls.count()).toBe(2);
500
501
expect(traverseFn).toHaveBeenCalledWith(
502
null,
@@ -516,7 +516,7 @@ describe('traverseAllChildren', function() {
516
it('should throw on object', function() {
517
expect(function() {
518
traverseAllChildren({a: 1, b: 2}, function() {}, null);
519
- }).toThrow(
519
+ }).toThrowError(
520
'Objects are not valid as a React child (found: object with keys ' +
521
'{a, b}). If you meant to render a collection of children, use an ' +
522
'array instead or wrap the object using createFragment(object) from ' +
@@ -529,7 +529,7 @@ describe('traverseAllChildren', function() {
529
// serialization (timezones) so let's test a regex instead:
530
expect(function() {
531
traverseAllChildren(/abc/, function() {}, null);
532
- }).toThrow(
532
+ }).toThrowError(
533
'Objects are not valid as a React child (found: /abc/). If you meant ' +
534
'to render a collection of children, use an array instead or wrap the ' +
535
'object using createFragment(object) from the React add-ons.'
src/test/MetaMatchers.js
+24
-17
@@ -32,6 +32,7 @@ function getRunnerWithResults(describeFunction) {
32
return env;
33
};
34
// TODO: Bring over matchers from the existing environment.
35
+ console.error(env);
36
var runner = env.currentRunner();
37
try {
38
env.describe('', describeFunction);
@@ -104,24 +105,30 @@ function compareRunners(actual, expected) {
105
}
106
107
var MetaMatchers = {
107
- toEqualSpecsIn: function(expectedDescribeFunction) {
108
- var actualDescribeFunction = this.actual;
109
- if (typeof actualDescribeFunction !== 'function') {
110
- throw Error('toEqualSpecsIn() should be used on a describe function');
111
- }
112
- if (typeof expectedDescribeFunction !== 'function') {
113
- throw Error('toEqualSpecsIn() should be passed a describe function');
114
- }
115
- var actual = getRunnerWithResults(actualDescribeFunction);
116
- var expected = getRunnerWithResults(expectedDescribeFunction);
117
- var errorMessage = compareRunners(actual, expected);
118
- this.message = function() {
119
- return [
120
- errorMessage,
121
- 'The specs are equal. Expected them to be different.',
122
- ];
108
+ toEqualSpecsIn(/* util, customEqualityMatcher*/) {
109
+ return {
110
+ compare(actualDescribeFunction, expectedDescribeFunction) {
111
+ if (typeof actualDescribeFunction !== 'function') {
112
+ throw Error('toEqualSpecsIn() should be used on a describe function');
113
+ }
114
+ if (typeof expectedDescribeFunction !== 'function') {
115
+ throw Error('toEqualSpecsIn() should be passed a describe function');
116
+ }
117
+ var actual = getRunnerWithResults(actualDescribeFunction);
118
+ var expected = getRunnerWithResults(expectedDescribeFunction);
119
+ var errorMessage = compareRunners(actual, expected);
120
+
121
+ return {
122
+ passed: !errorMessage,
123
+ message: function() {
124
+ return [
125
+ errorMessage,
126
+ 'The specs are equal. Expected them to be different.',
127
+ ];
128
+ },
129
+ };
130
+ },
131
};
124
- return !errorMessage;
132
},
133
};
134
src/test/__tests__/MetaMatchers-test.js
+1
-1
@@ -16,7 +16,7 @@ var MetaMatchers = require('MetaMatchers');
16
describe('meta-matchers', function() {
17
18
beforeEach(function() {
19
- this.addMatchers(MetaMatchers);
19
+ jasmine.addMatchers(MetaMatchers);
20
});
21
22
function a() {
src/test/__tests__/ReactTestUtils-test.js
+5
-5
@@ -75,12 +75,12 @@ describe('ReactTestUtils', function() {
75
});
76
77
var shallowRenderer = ReactTestUtils.createRenderer();
78
- expect(() => shallowRenderer.render(SomeComponent)).toThrow(
78
+ expect(() => shallowRenderer.render(SomeComponent)).toThrowError(
79
'ReactShallowRenderer render(): Invalid component element. Instead of ' +
80
'passing a component class, make sure to instantiate it by passing it ' +
81
'to React.createElement.'
82
);
83
- expect(() => shallowRenderer.render(<div />)).toThrow(
83
+ expect(() => shallowRenderer.render(<div />)).toThrowError(
84
'ReactShallowRenderer render(): Shallow rendering works only with ' +
85
'custom components, not primitives (div). Instead of calling ' +
86
'`.render(el)` and inspecting the rendered output, look at `el.props` ' +
@@ -458,7 +458,7 @@ describe('ReactTestUtils', function() {
458
e.persist();
459
},
460
};
461
- spyOn(obj, 'handler').andCallThrough();
461
+ spyOn(obj, 'handler').and.callThrough();
462
var container = document.createElement('div');
463
var instance = ReactDOM.render(<input type="text" onChange={obj.handler} />, container);
464
@@ -485,7 +485,7 @@ describe('ReactTestUtils', function() {
485
e.persist();
486
},
487
};
488
- spyOn(obj, 'handler').andCallThrough();
488
+ spyOn(obj, 'handler').and.callThrough();
489
var container = document.createElement('div');
490
var instance = ReactDOM.render(<SomeComponent handleChange={obj.handler} />, container);
491
@@ -510,7 +510,7 @@ describe('ReactTestUtils', function() {
510
var shallowRenderer = ReactTestUtils.createRenderer();
511
var result = shallowRenderer.render(<SomeComponent handleClick={handler} />);
512
513
- expect(() => ReactTestUtils.Simulate.click(result)).toThrow(
513
+ expect(() => ReactTestUtils.Simulate.click(result)).toThrowError(
514
'TestUtils.Simulate expects a component instance and not a ReactElement.' +
515
'TestUtils.Simulate will not work if you are using shallow rendering.'
516
);