I wrote it live! (#7663)
Christopher Chedeau committed
Sep 6, 2016 at 15:18 UTC
334b8bdf165c47336b467a4092e3f51893a83c0d
107 files changed
+1420
-1420
scripts/error-codes/__tests__/dev-expression-with-codes-test.js
+1
-1
@@ -25,7 +25,7 @@ function compare(input, output) {
25
26
var oldEnv;
27
28
-describe('dev-expression', function() {
28
+describe('dev-expression', () => {
29
beforeEach(() => {
30
oldEnv = process.env.NODE_ENV;
31
process.env.NODE_ENV = '';
src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js
+4
-4
@@ -15,16 +15,16 @@ var React;
15
var ReactComponentWithPureRenderMixin;
16
var ReactTestUtils;
17
18
-describe('ReactComponentWithPureRenderMixin', function() {
18
+describe('ReactComponentWithPureRenderMixin', () => {
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
React = require('React');
22
ReactComponentWithPureRenderMixin =
23
require('ReactComponentWithPureRenderMixin');
24
ReactTestUtils = require('ReactTestUtils');
25
});
26
27
- it('provides a default shouldComponentUpdate implementation', function() {
27
+ it('provides a default shouldComponentUpdate implementation', () => {
28
var renderCalls = 0;
29
class PlasticWrap extends React.Component {
30
constructor(props, context) {
@@ -97,7 +97,7 @@ describe('ReactComponentWithPureRenderMixin', function() {
97
expect(renderCalls).toBe(4);
98
});
99
100
- it('does not do a deep comparison', function() {
100
+ it('does not do a deep comparison', () => {
101
function getInitialState() {
102
return {
103
foo: [1, 2, 3],
src/addons/__tests__/ReactFragment-test.js
+9
-9
@@ -15,15 +15,15 @@ var React;
15
var ReactDOM;
16
var ReactFragment;
17
18
-describe('ReactFragment', function() {
18
+describe('ReactFragment', () => {
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
React = require('React');
22
ReactDOM = require('ReactDOM');
23
ReactFragment = require('ReactFragment');
24
});
25
26
- it('should throw if a plain object is used as a child', function() {
26
+ it('should throw if a plain object is used as a child', () => {
27
var children = {
28
x: <span />,
29
y: <span />,
@@ -39,7 +39,7 @@ describe('ReactFragment', function() {
39
);
40
});
41
42
- it('should throw if a plain object even if it is in an owner', function() {
42
+ it('should throw if a plain object even if it is in an owner', () => {
43
class Foo extends React.Component {
44
render() {
45
var children = {
@@ -59,7 +59,7 @@ describe('ReactFragment', function() {
59
);
60
});
61
62
- it('should throw if a plain object looks like an old element', function() {
62
+ it('should throw if a plain object looks like an old element', () => {
63
var oldEl = {_isReactElement: true, type: 'span', props: {}};
64
var container = document.createElement('div');
65
expect(() => ReactDOM.render(<div>{oldEl}</div>, container)).toThrowError(
@@ -70,7 +70,7 @@ describe('ReactFragment', function() {
70
);
71
});
72
73
- it('warns for numeric keys on objects as children', function() {
73
+ it('warns for numeric keys on objects as children', () => {
74
spyOn(console, 'error');
75
76
ReactFragment.create({1: <span />, 2: <span />});
@@ -81,7 +81,7 @@ describe('ReactFragment', function() {
81
);
82
});
83
84
- it('should warn if passing null to createFragment', function() {
84
+ it('should warn if passing null to createFragment', () => {
85
spyOn(console, 'error');
86
ReactFragment.create(null);
87
expect(console.error.calls.count()).toBe(1);
@@ -90,7 +90,7 @@ describe('ReactFragment', function() {
90
);
91
});
92
93
- it('should warn if passing an array to createFragment', function() {
93
+ it('should warn if passing an array to createFragment', () => {
94
spyOn(console, 'error');
95
ReactFragment.create([]);
96
expect(console.error.calls.count()).toBe(1);
@@ -99,7 +99,7 @@ describe('ReactFragment', function() {
99
);
100
});
101
102
- it('should warn if passing a ReactElement to createFragment', function() {
102
+ it('should warn if passing a ReactElement to createFragment', () => {
103
spyOn(console, 'error');
104
ReactFragment.create(<div />);
105
expect(console.error.calls.count()).toBe(1);
src/addons/__tests__/renderSubtreeIntoContainer-test.js
+5
-5
@@ -16,9 +16,9 @@ var ReactDOM = require('ReactDOM');
16
var ReactTestUtils = require('ReactTestUtils');
17
var renderSubtreeIntoContainer = require('renderSubtreeIntoContainer');
18
19
-describe('renderSubtreeIntoContainer', function() {
19
+describe('renderSubtreeIntoContainer', () => {
20
21
- it('should pass context when rendering subtree elsewhere', function() {
21
+ it('should pass context when rendering subtree elsewhere', () => {
22
var portal = document.createElement('div');
23
24
class Component extends React.Component {
@@ -57,7 +57,7 @@ describe('renderSubtreeIntoContainer', function() {
57
expect(portal.firstChild.innerHTML).toBe('bar');
58
});
59
60
- it('should throw if parentComponent is invalid', function() {
60
+ it('should throw if parentComponent is invalid', () => {
61
var portal = document.createElement('div');
62
63
class Component extends React.Component {
@@ -93,7 +93,7 @@ describe('renderSubtreeIntoContainer', function() {
93
}
94
});
95
96
- it('should update context if it changes due to setState', function() {
96
+ it('should update context if it changes due to setState', () => {
97
var container = document.createElement('div');
98
document.body.appendChild(container);
99
var portal = document.createElement('div');
@@ -145,7 +145,7 @@ describe('renderSubtreeIntoContainer', function() {
145
expect(portal.firstChild.innerHTML).toBe('changed-changed');
146
});
147
148
- it('should update context if it changes due to re-render', function() {
148
+ it('should update context if it changes due to re-render', () => {
149
var container = document.createElement('div');
150
document.body.appendChild(container);
151
var portal = document.createElement('div');
src/addons/__tests__/update-test.js
+31
-31
@@ -13,62 +13,62 @@
13
14
var update = require('update');
15
16
-describe('update', function() {
16
+describe('update', () => {
17
18
- describe('$push', function() {
19
- it('pushes', function() {
18
+ describe('$push', () => {
19
+ it('pushes', () => {
20
expect(update([1], {$push: [7]})).toEqual([1, 7]);
21
});
22
- it('does not mutate the original object', function() {
22
+ it('does not mutate the original object', () => {
23
var obj = [1];
24
update(obj, {$push: [7]});
25
expect(obj).toEqual([1]);
26
});
27
- it('only pushes an array', function() {
27
+ it('only pushes an array', () => {
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() {
33
+ it('only pushes unto an array', () => {
34
expect(update.bind(null, 1, {$push: 7})).toThrowError(
35
'update(): expected target of $push to be an array; got 1.'
36
);
37
});
38
});
39
40
- describe('$unshift', function() {
41
- it('unshifts', function() {
40
+ describe('$unshift', () => {
41
+ it('unshifts', () => {
42
expect(update([1], {$unshift: [7]})).toEqual([7, 1]);
43
});
44
- it('does not mutate the original object', function() {
44
+ it('does not mutate the original object', () => {
45
var obj = [1];
46
update(obj, {$unshift: [7]});
47
expect(obj).toEqual([1]);
48
});
49
- it('only unshifts an array', function() {
49
+ it('only unshifts an array', () => {
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() {
55
+ it('only unshifts unto an array', () => {
56
expect(update.bind(null, 1, {$unshift: 7})).toThrowError(
57
'update(): expected target of $unshift to be an array; got 1.'
58
);
59
});
60
});
61
62
- describe('$splice', function() {
63
- it('splices', function() {
62
+ describe('$splice', () => {
63
+ it('splices', () => {
64
expect(update([1, 4, 3], {$splice: [[1, 1, 2]]})).toEqual([1, 2, 3]);
65
});
66
- it('does not mutate the original object', function() {
66
+ it('does not mutate the original object', () => {
67
var obj = [1, 4, 3];
68
update(obj, {$splice: [[1, 1, 2]]});
69
expect(obj).toEqual([1, 4, 3]);
70
});
71
- it('only splices an array of arrays', function() {
71
+ it('only splices an array of arrays', () => {
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?'
@@ -78,65 +78,65 @@ describe('update', function() {
78
'Did you forget to wrap your parameters in an array?'
79
);
80
});
81
- it('only splices unto an array', function() {
81
+ it('only splices unto an array', () => {
82
expect(update.bind(null, 1, {$splice: 7})).toThrowError(
83
'Expected $splice target to be an array; got 1'
84
);
85
});
86
});
87
88
- describe('$merge', function() {
89
- it('merges', function() {
88
+ describe('$merge', () => {
89
+ it('merges', () => {
90
expect(update({a: 'b'}, {$merge: {c: 'd'}})).toEqual({a: 'b', c: 'd'});
91
});
92
- it('does not mutate the original object', function() {
92
+ it('does not mutate the original object', () => {
93
var obj = {a: 'b'};
94
update(obj, {$merge: {c: 'd'}});
95
expect(obj).toEqual({a: 'b'});
96
});
97
- it('only merges with an object', function() {
97
+ it('only merges with an object', () => {
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() {
102
+ it('only merges with an object', () => {
103
expect(update.bind(null, 7, {$merge: {a: 'b'}})).toThrowError(
104
'update(): $merge expects a target of type \'object\'; got 7'
105
);
106
});
107
});
108
109
- describe('$set', function() {
110
- it('sets', function() {
109
+ describe('$set', () => {
110
+ it('sets', () => {
111
expect(update({a: 'b'}, {$set: {c: 'd'}})).toEqual({c: 'd'});
112
});
113
- it('does not mutate the original object', function() {
113
+ it('does not mutate the original object', () => {
114
var obj = {a: 'b'};
115
update(obj, {$set: {c: 'd'}});
116
expect(obj).toEqual({a: 'b'});
117
});
118
});
119
120
- describe('$apply', function() {
120
+ describe('$apply', () => {
121
var applier = function(node) {
122
return {v: node.v * 2};
123
};
124
- it('applies', function() {
124
+ it('applies', () => {
125
expect(update({v: 2}, {$apply: applier})).toEqual({v: 4});
126
});
127
- it('does not mutate the original object', function() {
127
+ it('does not mutate the original object', () => {
128
var obj = {v: 2};
129
update(obj, {$apply: applier});
130
expect(obj).toEqual({v: 2});
131
});
132
- it('only applies a function', function() {
132
+ it('only applies a function', () => {
133
expect(update.bind(null, 2, {$apply: 123})).toThrowError(
134
'update(): expected spec of $apply to be a function; got 123.'
135
);
136
});
137
});
138
139
- it('should support deep updates', function() {
139
+ it('should support deep updates', () => {
140
expect(update({
141
a: 'b',
142
c: {
@@ -169,7 +169,7 @@ describe('update', function() {
169
});
170
});
171
172
- it('should require a command', function() {
172
+ it('should require a command', () => {
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 ' +
@@ -177,7 +177,7 @@ describe('update', function() {
177
);
178
});
179
180
- it('should perform safe hasOwnProperty check', function() {
180
+ it('should perform safe hasOwnProperty check', () => {
181
expect(update({}, {'hasOwnProperty': {$set: 'a'}})).toEqual({
182
'hasOwnProperty': 'a',
183
});
src/addons/link/__tests__/LinkedStateMixin-test.js
+3
-3
@@ -12,18 +12,18 @@
12
'use strict';
13
14
15
-describe('LinkedStateMixin', function() {
15
+describe('LinkedStateMixin', () => {
16
var LinkedStateMixin;
17
var React;
18
var ReactTestUtils;
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
LinkedStateMixin = require('LinkedStateMixin');
22
React = require('React');
23
ReactTestUtils = require('ReactTestUtils');
24
});
25
26
- it('should create a ReactLink for state', function() {
26
+ it('should create a ReactLink for state', () => {
27
var Component = React.createClass({
28
mixins: [LinkedStateMixin],
29
src/addons/link/__tests__/ReactLinkPropTypes-test.js
+9
-9
@@ -47,8 +47,8 @@ function typeCheckPass(declaration, value) {
47
expect(error).toBe(null);
48
}
49
50
-describe('ReactLink', function() {
51
- it('should fail if the argument does not implement the Link API', function() {
50
+describe('ReactLink', () => {
51
+ it('should fail if the argument does not implement the Link API', () => {
52
typeCheckFail(
53
LinkPropTypes.link(React.PropTypes.any),
54
{},
@@ -75,7 +75,7 @@ describe('ReactLink', function() {
75
);
76
});
77
78
- it('should allow valid links even if no type was specified', function() {
78
+ it('should allow valid links even if no type was specified', () => {
79
typeCheckPass(
80
LinkPropTypes.link(),
81
{value: 42, requestChange: emptyFunction}
@@ -86,14 +86,14 @@ describe('ReactLink', function() {
86
});
87
});
88
89
- it('should allow no link to be passed at all', function() {
89
+ it('should allow no link to be passed at all', () => {
90
typeCheckPass(
91
LinkPropTypes.link(React.PropTypes.string),
92
undefined
93
);
94
});
95
96
- it('should allow valid links with correct value format', function() {
96
+ it('should allow valid links with correct value format', () => {
97
typeCheckPass(
98
LinkPropTypes.link(React.PropTypes.any),
99
{value: 42, requestChange: emptyFunction}
@@ -108,7 +108,7 @@ describe('ReactLink', function() {
108
);
109
});
110
111
- it('should fail if the link`s value type does not match', function() {
111
+ it('should fail if the link`s value type does not match', () => {
112
typeCheckFail(
113
LinkPropTypes.link(React.PropTypes.string),
114
{value: 123, requestChange: emptyFunction},
@@ -117,14 +117,14 @@ describe('ReactLink', function() {
117
);
118
});
119
120
- it('should be implicitly optional and not warn without values', function() {
120
+ it('should be implicitly optional and not warn without values', () => {
121
typeCheckPass(LinkPropTypes.link(), null);
122
typeCheckPass(LinkPropTypes.link(), undefined);
123
typeCheckPass(LinkPropTypes.link(React.PropTypes.string), null);
124
typeCheckPass(LinkPropTypes.link(React.PropTypes.string), undefined);
125
});
126
127
- it('should warn for missing required values', function() {
127
+ it('should warn for missing required values', () => {
128
var specifiedButIsNullMsg = 'The prop `testProp` is marked as required ' +
129
'in `testComponent`, but its value is `null`.';
130
typeCheckFail(LinkPropTypes.link().isRequired, null, specifiedButIsNullMsg);
@@ -141,7 +141,7 @@ describe('ReactLink', function() {
141
);
142
});
143
144
- it('should be compatible with React.PropTypes.oneOfType', function() {
144
+ it('should be compatible with React.PropTypes.oneOfType', () => {
145
typeCheckPass(
146
React.PropTypes.oneOfType([LinkPropTypes.link(React.PropTypes.number)]),
147
{value: 123, requestChange: emptyFunction}
src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js
+14
-14
@@ -19,10 +19,10 @@ var ReactCSSTransitionGroup;
19
20
// Most of the real functionality is covered in other unit tests, this just
21
// makes sure we're wired up correctly.
22
-describe('ReactCSSTransitionGroup', function() {
22
+describe('ReactCSSTransitionGroup', () => {
23
var container;
24
25
- beforeEach(function() {
25
+ beforeEach(() => {
26
jest.resetModuleRegistry();
27
React = require('React');
28
ReactDOM = require('ReactDOM');
@@ -32,7 +32,7 @@ describe('ReactCSSTransitionGroup', function() {
32
spyOn(console, 'error');
33
});
34
35
- it('should warn if timeouts aren\'t specified', function() {
35
+ it('should warn if timeouts aren\'t specified', () => {
36
ReactDOM.render(
37
<ReactCSSTransitionGroup
38
transitionName="yolo"
@@ -48,7 +48,7 @@ describe('ReactCSSTransitionGroup', function() {
48
expect(console.error.calls.count()).toBe(1);
49
});
50
51
- it('should not warn if timeouts is zero', function() {
51
+ it('should not warn if timeouts is zero', () => {
52
ReactDOM.render(
53
<ReactCSSTransitionGroup
54
transitionName="yolo"
@@ -64,7 +64,7 @@ describe('ReactCSSTransitionGroup', function() {
64
expect(console.error.calls.count()).toBe(0);
65
});
66
67
- it('should clean-up silently after the timeout elapses', function() {
67
+ it('should clean-up silently after the timeout elapses', () => {
68
var a = ReactDOM.render(
69
<ReactCSSTransitionGroup
70
transitionName="yolo"
@@ -110,7 +110,7 @@ describe('ReactCSSTransitionGroup', function() {
110
expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('two');
111
});
112
113
- it('should keep both sets of DOM nodes around', function() {
113
+ it('should keep both sets of DOM nodes around', () => {
114
var a = ReactDOM.render(
115
<ReactCSSTransitionGroup transitionName="yolo">
116
<span key="one" id="one" />
@@ -129,7 +129,7 @@ describe('ReactCSSTransitionGroup', function() {
129
expect(ReactDOM.findDOMNode(a).childNodes[1].id).toBe('one');
130
});
131
132
- it('should switch transitionLeave from false to true', function() {
132
+ it('should switch transitionLeave from false to true', () => {
133
var a = ReactDOM.render(
134
<ReactCSSTransitionGroup
135
transitionName="yolo"
@@ -164,14 +164,14 @@ describe('ReactCSSTransitionGroup', function() {
164
expect(ReactDOM.findDOMNode(a).childNodes[1].id).toBe('two');
165
});
166
167
- it('should work with no children', function() {
167
+ it('should work with no children', () => {
168
ReactDOM.render(
169
<ReactCSSTransitionGroup transitionName="yolo" />,
170
container
171
);
172
});
173
174
- it('should work with a null child', function() {
174
+ it('should work with a null child', () => {
175
ReactDOM.render(
176
<ReactCSSTransitionGroup transitionName="yolo">
177
{[null]}
@@ -180,7 +180,7 @@ describe('ReactCSSTransitionGroup', function() {
180
);
181
});
182
183
- it('should transition from one to null', function() {
183
+ it('should transition from one to null', () => {
184
var a = ReactDOM.render(
185
<ReactCSSTransitionGroup transitionName="yolo">
186
<span key="one" id="one" />
@@ -200,7 +200,7 @@ describe('ReactCSSTransitionGroup', function() {
200
expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('one');
201
});
202
203
- it('should transition from false to one', function() {
203
+ it('should transition from false to one', () => {
204
var a = ReactDOM.render(
205
<ReactCSSTransitionGroup transitionName="yolo">
206
{false}
@@ -218,7 +218,7 @@ describe('ReactCSSTransitionGroup', function() {
218
expect(ReactDOM.findDOMNode(a).childNodes[0].id).toBe('one');
219
});
220
221
- it('should use transition-type specific names when they\'re provided', function() {
221
+ it('should use transition-type specific names when they\'re provided', () => {
222
var customTransitionNames = {
223
enter: 'custom-entering',
224
leave: 'custom-leaving',
@@ -270,7 +270,7 @@ describe('ReactCSSTransitionGroup', function() {
270
expect(CSSCore.hasClass(leavingNode, 'custom-leaving')).toBe(true);
271
});
272
273
- it('should clear transition timeouts when unmounted', function() {
273
+ it('should clear transition timeouts when unmounted', () => {
274
class Component extends React.Component {
275
render() {
276
return (
@@ -292,7 +292,7 @@ describe('ReactCSSTransitionGroup', function() {
292
jest.runAllTimers();
293
});
294
295
- it('should handle unmounted elements properly', function() {
295
+ it('should handle unmounted elements properly', () => {
296
class Child extends React.Component {
297
render() {
298
if (!this.props.show) {
src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js
+8
-8
@@ -14,13 +14,13 @@
14
var React;
15
var ReactTransitionChildMapping;
16
17
-describe('ReactTransitionChildMapping', function() {
18
- beforeEach(function() {
17
+describe('ReactTransitionChildMapping', () => {
18
+ beforeEach(() => {
19
React = require('React');
20
ReactTransitionChildMapping = require('ReactTransitionChildMapping');
21
});
22
23
- it('should support getChildMapping', function() {
23
+ it('should support getChildMapping', () => {
24
var oneone = <div key="oneone" />;
25
var onetwo = <div key="onetwo" />;
26
var one = <div key="one">{oneone}{onetwo}</div>;
@@ -34,7 +34,7 @@ describe('ReactTransitionChildMapping', function() {
34
});
35
});
36
37
- it('should support mergeChildMappings for adding keys', function() {
37
+ it('should support mergeChildMappings for adding keys', () => {
38
var prev = {
39
one: true,
40
two: true,
@@ -51,7 +51,7 @@ describe('ReactTransitionChildMapping', function() {
51
});
52
});
53
54
- it('should support mergeChildMappings for removing keys', function() {
54
+ it('should support mergeChildMappings for removing keys', () => {
55
var prev = {
56
one: true,
57
two: true,
@@ -68,7 +68,7 @@ describe('ReactTransitionChildMapping', function() {
68
});
69
});
70
71
- it('should support mergeChildMappings for adding and removing', function() {
71
+ it('should support mergeChildMappings for adding and removing', () => {
72
var prev = {
73
one: true,
74
two: true,
@@ -87,7 +87,7 @@ describe('ReactTransitionChildMapping', function() {
87
});
88
});
89
90
- it('should reconcile overlapping insertions and deletions', function() {
90
+ it('should reconcile overlapping insertions and deletions', () => {
91
var prev = {
92
one: true,
93
two: true,
@@ -109,7 +109,7 @@ describe('ReactTransitionChildMapping', function() {
109
});
110
});
111
112
- it('should support mergeChildMappings with undefined input', function() {
112
+ it('should support mergeChildMappings with undefined input', () => {
113
var prev = {
114
one: true,
115
two: true,
src/addons/transitions/__tests__/ReactTransitionGroup-test.js
+7
-7
@@ -17,14 +17,14 @@ var ReactTransitionGroup;
17
18
// Most of the real functionality is covered in other unit tests, this just
19
// makes sure we're wired up correctly.
20
-describe('ReactTransitionGroup', function() {
20
+describe('ReactTransitionGroup', () => {
21
var container;
22
23
function normalizeCodeLocInfo(str) {
24
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
25
}
26
27
- beforeEach(function() {
27
+ beforeEach(() => {
28
React = require('React');
29
ReactDOM = require('ReactDOM');
30
ReactTransitionGroup = require('ReactTransitionGroup');
@@ -33,7 +33,7 @@ describe('ReactTransitionGroup', function() {
33
});
34
35
36
- it('should handle willEnter correctly', function() {
36
+ it('should handle willEnter correctly', () => {
37
var log = [];
38
39
class Child extends React.Component {
@@ -103,7 +103,7 @@ describe('ReactTransitionGroup', function() {
103
});
104
});
105
106
- it('should handle enter/leave/enter/leave correctly', function() {
106
+ it('should handle enter/leave/enter/leave correctly', () => {
107
var log = [];
108
var willEnterCb;
109
@@ -168,7 +168,7 @@ describe('ReactTransitionGroup', function() {
168
]);
169
});
170
171
- it('should handle enter/leave/enter correctly', function() {
171
+ it('should handle enter/leave/enter correctly', () => {
172
var log = [];
173
var willEnterCb;
174
@@ -231,7 +231,7 @@ describe('ReactTransitionGroup', function() {
231
]);
232
});
233
234
- it('should handle entering/leaving several elements at once', function() {
234
+ it('should handle entering/leaving several elements at once', () => {
235
var log = [];
236
237
class Child extends React.Component {
@@ -296,7 +296,7 @@ describe('ReactTransitionGroup', function() {
296
]);
297
});
298
299
- it('should warn for duplicated keys with component stack info', function() {
299
+ it('should warn for duplicated keys with component stack info', () => {
300
spyOn(console, 'error');
301
302
class Component extends React.Component {
src/isomorphic/children/__tests__/ReactChildren-test.js
+19
-19
@@ -11,18 +11,18 @@
11
12
'use strict';
13
14
-describe('ReactChildren', function() {
14
+describe('ReactChildren', () => {
15
var ReactChildren;
16
var React;
17
var ReactFragment;
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
ReactChildren = require('ReactChildren');
21
React = require('React');
22
ReactFragment = require('ReactFragment');
23
});
24
25
- it('should support identity for simple', function() {
25
+ it('should support identity for simple', () => {
26
var callback = jasmine.createSpy().and.callFake(function(kid, index) {
27
return kid;
28
});
@@ -41,7 +41,7 @@ describe('ReactChildren', function() {
41
expect(mappedChildren[0]).toEqual(<span key=".$simple" />);
42
});
43
44
- it('should treat single arrayless child as being in array', function() {
44
+ it('should treat single arrayless child as being in array', () => {
45
var callback = jasmine.createSpy().and.callFake(function(kid, index) {
46
return kid;
47
});
@@ -56,7 +56,7 @@ describe('ReactChildren', function() {
56
expect(mappedChildren[0]).toEqual(<span key=".0" />);
57
});
58
59
- it('should treat single child in array as expected', function() {
59
+ it('should treat single child in array as expected', () => {
60
var callback = jasmine.createSpy().and.callFake(function(kid, index) {
61
return kid;
62
});
@@ -72,7 +72,7 @@ describe('ReactChildren', function() {
72
73
});
74
75
- it('should pass key to returned component', function() {
75
+ it('should pass key to returned component', () => {
76
var mapFn = function(kid, index) {
77
return <div>{kid}</div>;
78
};
@@ -88,7 +88,7 @@ describe('ReactChildren', function() {
88
expect(mappedChildren[0].key).toBe('.$simple');
89
});
90
91
- it('should invoke callback with the right context', function() {
91
+ it('should invoke callback with the right context', () => {
92
var lastContext;
93
var callback = function(kid, index) {
94
lastContext = this;
@@ -110,7 +110,7 @@ describe('ReactChildren', function() {
110
expect(mappedChildren[0]).toBe(scopeTester);
111
});
112
113
- it('should be called for each child', function() {
113
+ it('should be called for each child', () => {
114
var zero = <div key="keyZero" />;
115
var one = null;
116
var two = <div key="keyTwo" />;
@@ -172,7 +172,7 @@ describe('ReactChildren', function() {
172
expect(mappedChildren[3]).toEqual(<div key=".$keyFour" />);
173
});
174
175
- it('should be called for each child in nested structure', function() {
175
+ it('should be called for each child in nested structure', () => {
176
var zero = <div key="keyZero" />;
177
var one = null;
178
var two = <div key="keyTwo" />;
@@ -250,7 +250,7 @@ describe('ReactChildren', function() {
250
expect(mappedChildren[3]).toEqual(<div key=".0:$keyFive/.$keyFiveInner" />);
251
});
252
253
- it('should retain key across two mappings', function() {
253
+ it('should retain key across two mappings', () => {
254
var zeroForceKey = <div key="keyZero" />;
255
var oneForceKey = <div key="keyOne" />;
256
@@ -288,7 +288,7 @@ describe('ReactChildren', function() {
288
289
});
290
291
- it('should not throw if key provided is a dupe with array key', function() {
291
+ it('should not throw if key provided is a dupe with array key', () => {
292
var zero = <div />;
293
var one = <div key="0" />;
294
@@ -308,7 +308,7 @@ describe('ReactChildren', function() {
308
}).not.toThrow();
309
});
310
311
- it('should use the same key for a cloned element', function() {
311
+ it('should use the same key for a cloned element', () => {
312
var instance = (
313
<div>
314
<div />
@@ -328,7 +328,7 @@ describe('ReactChildren', function() {
328
expect(mapped[0].key).toBe(mappedWithClone[0].key);
329
});
330
331
- it('should use the same key for a cloned element with key', function() {
331
+ it('should use the same key for a cloned element with key', () => {
332
var instance = (
333
<div>
334
<div key="unique" />
@@ -348,24 +348,24 @@ describe('ReactChildren', function() {
348
expect(mapped[0].key).toBe(mappedWithClone[0].key);
349
});
350
351
- it('should return 0 for null children', function() {
351
+ it('should return 0 for null children', () => {
352
var numberOfChildren = ReactChildren.count(null);
353
expect(numberOfChildren).toBe(0);
354
});
355
356
- it('should return 0 for undefined children', function() {
356
+ it('should return 0 for undefined children', () => {
357
var numberOfChildren = ReactChildren.count(undefined);
358
expect(numberOfChildren).toBe(0);
359
});
360
361
- it('should return 1 for single child', function() {
361
+ it('should return 1 for single child', () => {
362
var simpleKid = <span key="simple" />;
363
var instance = <div>{simpleKid}</div>;
364
var numberOfChildren = ReactChildren.count(instance.props.children);
365
expect(numberOfChildren).toBe(1);
366
});
367
368
- it('should count the number of children in flat structure', function() {
368
+ it('should count the number of children in flat structure', () => {
369
var zero = <div key="keyZero" />;
370
var one = null;
371
var two = <div key="keyTwo" />;
@@ -385,7 +385,7 @@ describe('ReactChildren', function() {
385
expect(numberOfChildren).toBe(5);
386
});
387
388
- it('should count the number of children in nested structure', function() {
388
+ it('should count the number of children in nested structure', () => {
389
var zero = <div key="keyZero" />;
390
var one = null;
391
var two = <div key="keyTwo" />;
@@ -414,7 +414,7 @@ describe('ReactChildren', function() {
414
expect(numberOfChildren).toBe(5);
415
});
416
417
- it('should flatten children to an array', function() {
417
+ it('should flatten children to an array', () => {
418
expect(ReactChildren.toArray(undefined)).toEqual([]);
419
expect(ReactChildren.toArray(null)).toEqual([]);
420
src/isomorphic/children/__tests__/onlyChild-test.js
+7
-7
@@ -11,14 +11,14 @@
11
12
'use strict';
13
14
-describe('onlyChild', function() {
14
+describe('onlyChild', () => {
15
16
var React;
17
var ReactFragment;
18
var onlyChild;
19
var WrapComponent;
20
21
- beforeEach(function() {
21
+ beforeEach(() => {
22
React = require('React');
23
ReactFragment = require('ReactFragment');
24
onlyChild = require('onlyChild');
@@ -33,7 +33,7 @@ describe('onlyChild', function() {
33
};
34
});
35
36
- it('should fail when passed two children', function() {
36
+ it('should fail when passed two children', () => {
37
expect(function() {
38
var instance =
39
<WrapComponent>
@@ -44,7 +44,7 @@ describe('onlyChild', function() {
44
}).toThrow();
45
});
46
47
- it('should fail when passed nully values', function() {
47
+ it('should fail when passed nully values', () => {
48
expect(function() {
49
var instance =
50
<WrapComponent>
@@ -62,7 +62,7 @@ describe('onlyChild', function() {
62
}).toThrow();
63
});
64
65
- it('should fail when key/value objects', function() {
65
+ it('should fail when key/value objects', () => {
66
expect(function() {
67
var instance =
68
<WrapComponent>
@@ -73,7 +73,7 @@ describe('onlyChild', function() {
73
});
74
75
76
- it('should not fail when passed interpolated single child', function() {
76
+ it('should not fail when passed interpolated single child', () => {
77
expect(function() {
78
var instance =
79
<WrapComponent>
@@ -84,7 +84,7 @@ describe('onlyChild', function() {
84
});
85
86
87
- it('should return the only child', function() {
87
+ it('should return the only child', () => {
88
expect(function() {
89
var instance =
90
<WrapComponent>
src/isomorphic/children/__tests__/sliceChildren-test.js
+7
-7
@@ -11,19 +11,19 @@
11
12
'use strict';
13
14
-describe('sliceChildren', function() {
14
+describe('sliceChildren', () => {
15
16
var React;
17
18
var sliceChildren;
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
React = require('React');
22
23
sliceChildren = require('sliceChildren');
24
});
25
26
- it('should render the whole set if start zero is supplied', function() {
26
+ it('should render the whole set if start zero is supplied', () => {
27
var fullSet = [
28
<div key="A" />,
29
<div key="B" />,
@@ -37,7 +37,7 @@ describe('sliceChildren', function() {
37
]);
38
});
39
40
- it('should render the remaining set if no end index is supplied', function() {
40
+ it('should render the remaining set if no end index is supplied', () => {
41
var fullSet = [
42
<div key="A" />,
43
<div key="B" />,
@@ -50,7 +50,7 @@ describe('sliceChildren', function() {
50
]);
51
});
52
53
- it('should exclude everything at or after the end index', function() {
53
+ it('should exclude everything at or after the end index', () => {
54
var fullSet = [
55
<div key="A" />,
56
<div key="B" />,
@@ -63,7 +63,7 @@ describe('sliceChildren', function() {
63
]);
64
});
65
66
- it('should allow static children to be sliced', function() {
66
+ it('should allow static children to be sliced', () => {
67
var a = <a />;
68
var b = <b />;
69
var c = <i />;
@@ -75,7 +75,7 @@ describe('sliceChildren', function() {
75
]);
76
});
77
78
- it('should slice nested children', function() {
78
+ it('should slice nested children', () => {
79
var fullSet = [
80
<div key="A" />,
81
[
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
+6
-6
@@ -23,12 +23,12 @@ var ReactTestUtils;
23
24
var reactComponentExpect;
25
26
-describe('ReactContextValidator', function() {
26
+describe('ReactContextValidator', () => {
27
function normalizeCodeLocInfo(str) {
28
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
29
}
30
31
- beforeEach(function() {
31
+ beforeEach(() => {
32
jest.resetModuleRegistry();
33
34
React = require('React');
@@ -40,7 +40,7 @@ describe('ReactContextValidator', function() {
40
// TODO: This behavior creates a runtime dependency on propTypes. We should
41
// ensure that this is not required for ES6 classes with Flow.
42
43
- it('should filter out context not in contextTypes', function() {
43
+ it('should filter out context not in contextTypes', () => {
44
var Component = React.createClass({
45
contextTypes: {
46
foo: React.PropTypes.string,
@@ -73,7 +73,7 @@ describe('ReactContextValidator', function() {
73
reactComponentExpect(instance).expectRenderedChild().scalarContextEqual({foo: 'abc'});
74
});
75
76
- it('should filter context properly in callbacks', function() {
76
+ it('should filter context properly in callbacks', () => {
77
var actualComponentWillReceiveProps;
78
var actualShouldComponentUpdate;
79
var actualComponentWillUpdate;
@@ -134,7 +134,7 @@ describe('ReactContextValidator', function() {
134
expect(actualComponentDidUpdate).toEqual({foo: 'abc'});
135
});
136
137
- it('should check context types', function() {
137
+ it('should check context types', () => {
138
spyOn(console, 'error');
139
140
var Component = React.createClass({
@@ -208,7 +208,7 @@ describe('ReactContextValidator', function() {
208
);
209
});
210
211
- it('should check child context types', function() {
211
+ it('should check child context types', () => {
212
spyOn(console, 'error');
213
214
var Component = React.createClass({
src/isomorphic/classic/class/__tests__/ReactBind-test.js
+5
-5
@@ -16,9 +16,9 @@ var ReactTestUtils = require('ReactTestUtils');
16
var reactComponentExpect = require('reactComponentExpect');
17
18
// TODO: Test render and all stock methods.
19
-describe('autobinding', function() {
19
+describe('autobinding', () => {
20
21
- it('Holds reference to instance', function() {
21
+ it('Holds reference to instance', () => {
22
23
var mouseDidEnter = jest.fn();
24
var mouseDidLeave = jest.fn();
@@ -94,7 +94,7 @@ describe('autobinding', function() {
94
expect(mouseDidLeave.mock.instances[1]).toBe(mountedInstance2);
95
});
96
97
- it('works with mixins', function() {
97
+ it('works with mixins', () => {
98
var mouseDidClick = jest.fn();
99
100
var TestMixin = {
@@ -120,7 +120,7 @@ describe('autobinding', function() {
120
expect(mouseDidClick.mock.instances[0]).toBe(mountedInstance1);
121
});
122
123
- it('warns if you try to bind to this', function() {
123
+ it('warns if you try to bind to this', () => {
124
spyOn(console, 'error');
125
126
var TestBindComponent = React.createClass({
@@ -140,7 +140,7 @@ describe('autobinding', function() {
140
);
141
});
142
143
- it('does not warn if you pass an auto-bound method to setState', function() {
143
+ it('does not warn if you pass an auto-bound method to setState', () => {
144
spyOn(console, 'error');
145
146
var TestBindComponent = React.createClass({
src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js
+7
-7
@@ -16,9 +16,9 @@ var ReactTestUtils = require('ReactTestUtils');
16
var reactComponentExpect = require('reactComponentExpect');
17
18
// TODO: Test render and all stock methods.
19
-describe('autobind optout', function() {
19
+describe('autobind optout', () => {
20
21
- it('should work with manual binding', function() {
21
+ it('should work with manual binding', () => {
22
23
var mouseDidEnter = jest.fn();
24
var mouseDidLeave = jest.fn();
@@ -81,7 +81,7 @@ describe('autobind optout', function() {
81
expect(mouseDidLeave.mock.instances[1]).toBe(mountedInstance2);
82
});
83
84
- it('should not hold reference to instance', function() {
84
+ it('should not hold reference to instance', () => {
85
var mouseDidClick = function() {
86
void this.state.something;
87
};
@@ -137,7 +137,7 @@ describe('autobind optout', function() {
137
}).toThrow();
138
});
139
140
- it('works with mixins that have not opted out of autobinding', function() {
140
+ it('works with mixins that have not opted out of autobinding', () => {
141
var mouseDidClick = jest.fn();
142
143
var TestMixin = {
@@ -163,7 +163,7 @@ describe('autobind optout', function() {
163
expect(mouseDidClick.mock.instances[0]).toBe(mountedInstance1);
164
});
165
166
- it('works with mixins that have opted out of autobinding', function() {
166
+ it('works with mixins that have opted out of autobinding', () => {
167
var mouseDidClick = jest.fn();
168
169
var TestMixin = {
@@ -190,7 +190,7 @@ describe('autobind optout', function() {
190
expect(mouseDidClick.mock.instances[0]).toBe(mountedInstance1);
191
});
192
193
- it('does not warn if you try to bind to this', function() {
193
+ it('does not warn if you try to bind to this', () => {
194
spyOn(console, 'error');
195
196
var TestBindComponent = React.createClass({
@@ -206,7 +206,7 @@ describe('autobind optout', function() {
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() {
209
+ it('does not warn if you pass an manually bound method to setState', () => {
210
spyOn(console, 'error');
211
212
var TestBindComponent = React.createClass({
src/isomorphic/classic/class/__tests__/ReactClass-test.js
+18
-18
@@ -15,15 +15,15 @@ var React;
15
var ReactDOM;
16
var ReactTestUtils;
17
18
-describe('ReactClass-spec', function() {
18
+describe('ReactClass-spec', () => {
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
React = require('React');
22
ReactDOM = require('ReactDOM');
23
ReactTestUtils = require('ReactTestUtils');
24
});
25
26
- it('should throw when `render` is not specified', function() {
26
+ it('should throw when `render` is not specified', () => {
27
expect(function() {
28
React.createClass({});
29
}).toThrowError(
@@ -31,7 +31,7 @@ describe('ReactClass-spec', function() {
31
);
32
});
33
34
- it('should copy `displayName` onto the Constructor', function() {
34
+ it('should copy `displayName` onto the Constructor', () => {
35
var TestComponent = React.createClass({
36
render: function() {
37
return <div />;
@@ -42,7 +42,7 @@ describe('ReactClass-spec', function() {
42
.toBe('TestComponent');
43
});
44
45
- it('should copy prop types onto the Constructor', function() {
45
+ it('should copy prop types onto the Constructor', () => {
46
var propValidator = jest.fn();
47
var TestComponent = React.createClass({
48
propTypes: {
@@ -58,7 +58,7 @@ describe('ReactClass-spec', function() {
58
.toBe(propValidator);
59
});
60
61
- it('should warn on invalid prop types', function() {
61
+ it('should warn on invalid prop types', () => {
62
spyOn(console, 'error');
63
React.createClass({
64
displayName: 'Component',
@@ -76,7 +76,7 @@ describe('ReactClass-spec', function() {
76
);
77
});
78
79
- it('should warn on invalid context types', function() {
79
+ it('should warn on invalid context types', () => {
80
spyOn(console, 'error');
81
React.createClass({
82
displayName: 'Component',
@@ -94,7 +94,7 @@ describe('ReactClass-spec', function() {
94
);
95
});
96
97
- it('should throw on invalid child context types', function() {
97
+ it('should throw on invalid child context types', () => {
98
spyOn(console, 'error');
99
React.createClass({
100
displayName: 'Component',
@@ -112,7 +112,7 @@ describe('ReactClass-spec', function() {
112
);
113
});
114
115
- it('should warn when mispelling shouldComponentUpdate', function() {
115
+ it('should warn when mispelling shouldComponentUpdate', () => {
116
spyOn(console, 'error');
117
118
React.createClass({
@@ -147,7 +147,7 @@ describe('ReactClass-spec', function() {
147
);
148
});
149
150
- it('should warn when mispelling componentWillReceiveProps', function() {
150
+ it('should warn when mispelling componentWillReceiveProps', () => {
151
spyOn(console, 'error');
152
React.createClass({
153
componentWillRecieveProps: function() {
@@ -164,7 +164,7 @@ describe('ReactClass-spec', function() {
164
);
165
});
166
167
- it('should throw if a reserved property is in statics', function() {
167
+ it('should throw if a reserved property is in statics', () => {
168
expect(function() {
169
React.createClass({
170
statics: {
@@ -189,7 +189,7 @@ describe('ReactClass-spec', function() {
189
190
// TODO: Consider actually moving these to statics or drop this unit test.
191
192
- xit('should warn when using deprecated non-static spec keys', function() {
192
+ xit('should warn when using deprecated non-static spec keys', () => {
193
spyOn(console, 'error');
194
React.createClass({
195
mixins: [{}],
@@ -225,7 +225,7 @@ describe('ReactClass-spec', function() {
225
);
226
});
227
228
- it('should support statics', function() {
228
+ it('should support statics', () => {
229
var Component = React.createClass({
230
statics: {
231
abc: 'def',
@@ -255,7 +255,7 @@ describe('ReactClass-spec', function() {
255
expect(Component.pqr()).toBe(Component);
256
});
257
258
- it('should work with object getInitialState() return values', function() {
258
+ it('should work with object getInitialState() return values', () => {
259
var Component = React.createClass({
260
getInitialState: function() {
261
return {
@@ -271,7 +271,7 @@ describe('ReactClass-spec', function() {
271
expect(instance.state.occupation).toEqual('clown');
272
});
273
274
- it('renders based on context getInitialState', function() {
274
+ it('renders based on context getInitialState', () => {
275
var Foo = React.createClass({
276
contextTypes: {
277
className: React.PropTypes.string,
@@ -301,7 +301,7 @@ describe('ReactClass-spec', function() {
301
expect(container.firstChild.className).toBe('foo');
302
});
303
304
- it('should throw with non-object getInitialState() return values', function() {
304
+ it('should throw with non-object getInitialState() return values', () => {
305
[['an array'], 'a string', 1234].forEach(function(state) {
306
var Component = React.createClass({
307
getInitialState: function() {
@@ -320,7 +320,7 @@ describe('ReactClass-spec', function() {
320
});
321
});
322
323
- it('should work with a null getInitialState() return value', function() {
323
+ it('should work with a null getInitialState() return value', () => {
324
var Component = React.createClass({
325
getInitialState: function() {
326
return null;
@@ -334,7 +334,7 @@ describe('ReactClass-spec', function() {
334
).not.toThrow();
335
});
336
337
- it('should throw when using legacy factories', function() {
337
+ it('should throw when using legacy factories', () => {
338
spyOn(console, 'error');
339
var Component = React.createClass({
340
render() {
src/isomorphic/classic/class/__tests__/ReactClassMixin-test.js
+21
-21
@@ -20,9 +20,9 @@ var TestComponentWithReverseSpec;
20
var mixinPropValidator;
21
var componentPropValidator;
22
23
-describe('ReactClass-mixin', function() {
23
+describe('ReactClass-mixin', () => {
24
25
- beforeEach(function() {
25
+ beforeEach(() => {
26
React = require('React');
27
ReactTestUtils = require('ReactTestUtils');
28
mixinPropValidator = jest.fn();
@@ -106,7 +106,7 @@ describe('ReactClass-mixin', function() {
106
});
107
});
108
109
- it('should support merging propTypes and statics', function() {
109
+ it('should support merging propTypes and statics', () => {
110
var listener = jest.fn();
111
var instance = <TestComponent listener={listener} />;
112
instance = ReactTestUtils.renderIntoDocument(instance);
@@ -121,7 +121,7 @@ describe('ReactClass-mixin', function() {
121
expect('staticComponent' in TestComponent).toBe(true);
122
});
123
124
- it('should support chaining delegate functions', function() {
124
+ it('should support chaining delegate functions', () => {
125
var listener = jest.fn();
126
var instance = <TestComponent listener={listener} />;
127
instance = ReactTestUtils.renderIntoDocument(instance);
@@ -134,7 +134,7 @@ describe('ReactClass-mixin', function() {
134
]);
135
});
136
137
- it('should chain functions regardless of spec property order', function() {
137
+ it('should chain functions regardless of spec property order', () => {
138
var listener = jest.fn();
139
var instance = <TestComponentWithReverseSpec listener={listener} />;
140
instance = ReactTestUtils.renderIntoDocument(instance);
@@ -147,13 +147,13 @@ describe('ReactClass-mixin', function() {
147
]);
148
});
149
150
- it('should validate prop types via mixins', function() {
150
+ it('should validate prop types via mixins', () => {
151
expect(TestComponent.propTypes).toBeDefined();
152
expect(TestComponent.propTypes.value)
153
.toBe(mixinPropValidator);
154
});
155
156
- it('should override mixin prop types with class prop types', function() {
156
+ it('should override mixin prop types with class prop types', () => {
157
// Sanity check...
158
expect(componentPropValidator).not.toBe(mixinPropValidator);
159
// Actually check...
@@ -166,7 +166,7 @@ describe('ReactClass-mixin', function() {
166
});
167
168
169
- it('should support mixins with getInitialState()', function() {
169
+ it('should support mixins with getInitialState()', () => {
170
var Mixin = {
171
getInitialState: function() {
172
return {mixin: true};
@@ -187,7 +187,7 @@ describe('ReactClass-mixin', function() {
187
expect(instance.state.mixin).toBe(true);
188
});
189
190
- it('should throw with conflicting getInitialState() methods', function() {
190
+ it('should throw with conflicting getInitialState() methods', () => {
191
var Mixin = {
192
getInitialState: function() {
193
return {x: true};
@@ -213,7 +213,7 @@ describe('ReactClass-mixin', function() {
213
);
214
});
215
216
- it('should not mutate objects returned by getInitialState()', function() {
216
+ it('should not mutate objects returned by getInitialState()', () => {
217
var Mixin = {
218
getInitialState: function() {
219
return Object.freeze({mixin: true});
@@ -233,7 +233,7 @@ describe('ReactClass-mixin', function() {
233
}).not.toThrow();
234
});
235
236
- it('should support statics in mixins', function() {
236
+ it('should support statics in mixins', () => {
237
var Mixin = {
238
statics: {
239
foo: 'bar',
@@ -258,7 +258,7 @@ describe('ReactClass-mixin', function() {
258
expect(Component.abc).toBe('def');
259
});
260
261
- it("should throw if mixins override each others' statics", function() {
261
+ it("should throw if mixins override each others' statics", () => {
262
expect(function() {
263
var Mixin = {
264
statics: {
@@ -282,7 +282,7 @@ describe('ReactClass-mixin', function() {
282
);
283
});
284
285
- it('should throw if mixins override functions in statics', function() {
285
+ it('should throw if mixins override functions in statics', () => {
286
expect(function() {
287
var Mixin = {
288
statics: {
@@ -310,7 +310,7 @@ describe('ReactClass-mixin', function() {
310
);
311
});
312
313
- it('should warn if the mixin is undefined', function() {
313
+ it('should warn if the mixin is undefined', () => {
314
spyOn(console, 'error');
315
316
React.createClass({
@@ -330,7 +330,7 @@ describe('ReactClass-mixin', function() {
330
);
331
});
332
333
- it('should warn if the mixin is null', function() {
333
+ it('should warn if the mixin is null', () => {
334
spyOn(console, 'error');
335
336
React.createClass({
@@ -350,7 +350,7 @@ describe('ReactClass-mixin', function() {
350
);
351
});
352
353
- it('should warn if an undefined mixin is included in another mixin', function() {
353
+ it('should warn if an undefined mixin is included in another mixin', () => {
354
spyOn(console, 'error');
355
356
var mixinA = {
@@ -374,7 +374,7 @@ describe('ReactClass-mixin', function() {
374
);
375
});
376
377
- it('should warn if a null mixin is included in another mixin', function() {
377
+ it('should warn if a null mixin is included in another mixin', () => {
378
spyOn(console, 'error');
379
380
var mixinA = {
@@ -398,7 +398,7 @@ describe('ReactClass-mixin', function() {
398
);
399
});
400
401
- it('should throw if the mixin is a React component', function() {
401
+ it('should throw if the mixin is a React component', () => {
402
expect(function() {
403
React.createClass({
404
mixins: [<div />],
@@ -413,7 +413,7 @@ describe('ReactClass-mixin', function() {
413
);
414
});
415
416
- it('should throw if the mixin is a React component class', function() {
416
+ it('should throw if the mixin is a React component class', () => {
417
expect(function() {
418
var Component = React.createClass({
419
render: function() {
@@ -434,7 +434,7 @@ describe('ReactClass-mixin', function() {
434
);
435
});
436
437
- it('should have bound the mixin methods to the component', function() {
437
+ it('should have bound the mixin methods to the component', () => {
438
var mixin = {
439
mixinFunc: function() {
440
return this;
@@ -454,7 +454,7 @@ describe('ReactClass-mixin', function() {
454
instance = ReactTestUtils.renderIntoDocument(instance);
455
});
456
457
- it('should include the mixin keys in even if their values are falsy', function() {
457
+ it('should include the mixin keys in even if their values are falsy', () => {
458
var mixin = {
459
keyWithNullValue: null,
460
randomCounter: 0,
src/isomorphic/classic/element/__tests__/ReactElement-test.js
+51
-51
@@ -15,11 +15,11 @@ var React;
15
var ReactDOM;
16
var ReactTestUtils;
17
18
-describe('ReactElement', function() {
18
+describe('ReactElement', () => {
19
var ComponentClass;
20
var originalSymbol;
21
22
- beforeEach(function() {
22
+ beforeEach(() => {
23
jest.resetModuleRegistry();
24
25
// Delete the native Symbol if we have one to ensure we test the
@@ -39,15 +39,15 @@ describe('ReactElement', function() {
39
});
40
});
41
42
- afterEach(function() {
42
+ afterEach(() => {
43
global.Symbol = originalSymbol;
44
});
45
46
- it('uses the fallback value when in an environment without Symbol', function() {
46
+ it('uses the fallback value when in an environment without Symbol', () => {
47
expect(<div />.$$typeof).toBe(0xeac7);
48
});
49
50
- it('returns a complete element according to spec', function() {
50
+ it('returns a complete element according to spec', () => {
51
var element = React.createFactory(ComponentClass)();
52
expect(element.type).toBe(ComponentClass);
53
expect(element.key).toBe(null);
@@ -57,7 +57,7 @@ describe('ReactElement', function() {
57
expect(element.props).toEqual({});
58
});
59
60
- it('should warn when `key` is being accessed on createClass element', function() {
60
+ it('should warn when `key` is being accessed on createClass element', () => {
61
spyOn(console, 'error');
62
var container = document.createElement('div');
63
var Child = React.createClass({
@@ -87,7 +87,7 @@ describe('ReactElement', function() {
87
);
88
});
89
90
- it('should warn when `key` is being accessed on ES class element', function() {
90
+ it('should warn when `key` is being accessed on ES class element', () => {
91
spyOn(console, 'error');
92
var container = document.createElement('div');
93
class Child extends React.Component {
@@ -117,7 +117,7 @@ describe('ReactElement', function() {
117
);
118
});
119
120
- it('should warn when `key` is being accessed on a host element', function() {
120
+ it('should warn when `key` is being accessed on a host element', () => {
121
spyOn(console, 'error');
122
var element = <div key="3" />;
123
expect(console.error.calls.count()).toBe(0);
@@ -131,7 +131,7 @@ describe('ReactElement', function() {
131
);
132
});
133
134
- it('should warn when `ref` is being accessed', function() {
134
+ it('should warn when `ref` is being accessed', () => {
135
spyOn(console, 'error');
136
var container = document.createElement('div');
137
var Child = React.createClass({
@@ -159,7 +159,7 @@ describe('ReactElement', function() {
159
);
160
});
161
162
- it('allows a string to be passed as the type', function() {
162
+ it('allows a string to be passed as the type', () => {
163
var element = React.createFactory('div')();
164
expect(element.type).toBe('div');
165
expect(element.key).toBe(null);
@@ -169,12 +169,12 @@ describe('ReactElement', function() {
169
expect(element.props).toEqual({});
170
});
171
172
- it('returns an immutable element', function() {
172
+ it('returns an immutable element', () => {
173
var element = React.createFactory(ComponentClass)();
174
expect(() => element.type = 'div').toThrow();
175
});
176
177
- it('does not reuse the original config object', function() {
177
+ it('does not reuse the original config object', () => {
178
var config = {foo: 1};
179
var element = React.createFactory(ComponentClass)(config);
180
expect(element.props.foo).toBe(1);
@@ -182,13 +182,13 @@ describe('ReactElement', function() {
182
expect(element.props.foo).toBe(1);
183
});
184
185
- it('does not fail if config has no prototype', function() {
185
+ it('does not fail if config has no prototype', () => {
186
var config = Object.create(null, {foo: {value: 1, enumerable: true}});
187
var element = React.createFactory(ComponentClass)(config);
188
expect(element.props.foo).toBe(1);
189
});
190
191
- it('warns if the config object inherits from any type other than Object', function() {
191
+ it('warns if the config object inherits from any type other than Object', () => {
192
spyOn(console, 'error');
193
React.createElement('div', {foo: 1});
194
expect(console.error).not.toHaveBeenCalled();
@@ -200,7 +200,7 @@ describe('ReactElement', function() {
200
);
201
});
202
203
- it('extracts key and ref from the config', function() {
203
+ it('extracts key and ref from the config', () => {
204
var element = React.createFactory(ComponentClass)({
205
key: '12',
206
ref: '34',
@@ -214,7 +214,7 @@ describe('ReactElement', function() {
214
expect(element.props).toEqual({foo: '56'});
215
});
216
217
- it('extracts null key and ref', function() {
217
+ it('extracts null key and ref', () => {
218
var element = React.createFactory(ComponentClass)({
219
key: null,
220
ref: null,
@@ -228,7 +228,7 @@ describe('ReactElement', function() {
228
expect(element.props).toEqual({foo: '12'});
229
});
230
231
- it('ignores undefined key and ref', function() {
231
+ it('ignores undefined key and ref', () => {
232
var props = {
233
foo: '56',
234
key: undefined,
@@ -243,14 +243,14 @@ describe('ReactElement', function() {
243
expect(element.props).toEqual({foo: '56'});
244
});
245
246
- it('ignores key and ref warning getters', function() {
246
+ it('ignores key and ref warning getters', () => {
247
var elementA = React.createElement('div');
248
var elementB = React.createElement('div', elementA.props);
249
expect(elementB.key).toBe(null);
250
expect(elementB.ref).toBe(null);
251
});
252
253
- it('coerces the key to a string', function() {
253
+ it('coerces the key to a string', () => {
254
var element = React.createFactory(ComponentClass)({
255
key: 12,
256
foo: '56',
@@ -263,7 +263,7 @@ describe('ReactElement', function() {
263
expect(element.props).toEqual({foo: '56'});
264
});
265
266
- it('preserves the owner on the element', function() {
266
+ it('preserves the owner on the element', () => {
267
var Component = React.createFactory(ComponentClass);
268
var element;
269
@@ -281,7 +281,7 @@ describe('ReactElement', function() {
281
expect(element._owner.getPublicInstance()).toBe(instance);
282
});
283
284
- it('merges an additional argument onto the children prop', function() {
284
+ it('merges an additional argument onto the children prop', () => {
285
spyOn(console, 'error');
286
var a = 1;
287
var element = React.createFactory(ComponentClass)({
@@ -291,7 +291,7 @@ describe('ReactElement', function() {
291
expect(console.error.calls.count()).toBe(0);
292
});
293
294
- it('does not override children if no rest args are provided', function() {
294
+ it('does not override children if no rest args are provided', () => {
295
spyOn(console, 'error');
296
var element = React.createFactory(ComponentClass)({
297
children: 'text',
@@ -300,7 +300,7 @@ describe('ReactElement', function() {
300
expect(console.error.calls.count()).toBe(0);
301
});
302
303
- it('overrides children if null is provided as an argument', function() {
303
+ it('overrides children if null is provided as an argument', () => {
304
spyOn(console, 'error');
305
var element = React.createFactory(ComponentClass)({
306
children: 'text',
@@ -309,7 +309,7 @@ describe('ReactElement', function() {
309
expect(console.error.calls.count()).toBe(0);
310
});
311
312
- it('merges rest arguments onto the children prop in an array', function() {
312
+ it('merges rest arguments onto the children prop in an array', () => {
313
spyOn(console, 'error');
314
var a = 1;
315
var b = 2;
@@ -321,7 +321,7 @@ describe('ReactElement', function() {
321
322
// NOTE: We're explicitly not using JSX here. This is intended to test
323
// classic JS without JSX.
324
- it('allows static methods to be called using the type property', function() {
324
+ it('allows static methods to be called using the type property', () => {
325
spyOn(console, 'error');
326
327
var StaticMethodComponentClass = React.createClass({
@@ -345,7 +345,7 @@ describe('ReactElement', function() {
345
346
// NOTE: We're explicitly not using JSX here. This is intended to test
347
// classic JS without JSX.
348
- it('identifies valid elements', function() {
348
+ it('identifies valid elements', () => {
349
var Component = React.createClass({
350
render: function() {
351
return React.createElement('div');
@@ -369,7 +369,7 @@ describe('ReactElement', function() {
369
expect(React.isValidElement(JSON.parse(jsonElement))).toBe(true);
370
});
371
372
- it('allows the use of PropTypes validators in statics', function() {
372
+ it('allows the use of PropTypes validators in statics', () => {
373
// TODO: This test was added to cover a special case where we proxied
374
// methods. However, we don't do that any more so this test can probably
375
// be removed. Leaving it in classic as a safety precaution.
@@ -386,7 +386,7 @@ describe('ReactElement', function() {
386
387
// NOTE: We're explicitly not using JSX here. This is intended to test
388
// classic JS without JSX.
389
- it('is indistinguishable from a plain object', function() {
389
+ it('is indistinguishable from a plain object', () => {
390
var element = React.createElement('div', {className: 'foo'});
391
var object = {};
392
expect(element.constructor).toBe(object.constructor);
@@ -394,7 +394,7 @@ describe('ReactElement', function() {
394
395
// NOTE: We're explicitly not using JSX here. This is intended to test
396
// classic JS without JSX.
397
- it('should use default prop value when removing a prop', function() {
397
+ it('should use default prop value when removing a prop', () => {
398
var Component = React.createClass({
399
getDefaultProps: function() {
400
return {fruit: 'persimmon'};
@@ -417,7 +417,7 @@ describe('ReactElement', function() {
417
418
// NOTE: We're explicitly not using JSX here. This is intended to test
419
// classic JS without JSX.
420
- it('should normalize props with default values', function() {
420
+ it('should normalize props with default values', () => {
421
var Component = React.createClass({
422
getDefaultProps: function() {
423
return {prop: 'testKey'};
@@ -438,7 +438,7 @@ describe('ReactElement', function() {
438
expect(inst2.props.prop).toBe(null);
439
});
440
441
- it('throws when changing a prop (in dev) after element creation', function() {
441
+ it('throws when changing a prop (in dev) after element creation', () => {
442
var Outer = React.createClass({
443
render: function() {
444
var el = <div className="moo" />;
@@ -455,7 +455,7 @@ describe('ReactElement', function() {
455
expect(ReactDOM.findDOMNode(outer).className).toBe('moo');
456
});
457
458
- it('throws when adding a prop (in dev) after element creation', function() {
458
+ it('throws when adding a prop (in dev) after element creation', () => {
459
var container = document.createElement('div');
460
var Outer = React.createClass({
461
getDefaultProps: () => ({sound: 'meow'}),
@@ -476,7 +476,7 @@ describe('ReactElement', function() {
476
expect(ReactDOM.findDOMNode(outer).className).toBe('');
477
});
478
479
- it('does not warn for NaN props', function() {
479
+ it('does not warn for NaN props', () => {
480
spyOn(console, 'error');
481
var Test = React.createClass({
482
render: function() {
@@ -490,7 +490,7 @@ describe('ReactElement', function() {
490
491
// NOTE: We're explicitly not using JSX here. This is intended to test
492
// classic JS without JSX.
493
- it('identifies elements, but not JSON, if Symbols are supported', function() {
493
+ it('identifies elements, but not JSON, if Symbols are supported', () => {
494
// Rudimentary polyfill
495
// Once all jest engines support Symbols natively we can swap this to test
496
// WITH native Symbols by default.
@@ -535,10 +535,10 @@ describe('ReactElement', function() {
535
536
});
537
538
-describe('comparing jsx vs .createFactory() vs .createElement()', function() {
538
+describe('comparing jsx vs .createFactory() vs .createElement()', () => {
539
var Child;
540
541
- beforeEach(function() {
541
+ beforeEach(() => {
542
jest.resetModuleRegistry();
543
React = require('React');
544
ReactDOM = require('ReactDOM');
@@ -547,9 +547,9 @@ describe('comparing jsx vs .createFactory() vs .createElement()', function() {
547
});
548
549
550
- describe('when using jsx only', function() {
550
+ describe('when using jsx only', () => {
551
var Parent, instance;
552
- beforeEach(function() {
552
+ beforeEach(() => {
553
Parent = React.createClass({
554
render: function() {
555
return (
@@ -562,23 +562,23 @@ describe('comparing jsx vs .createFactory() vs .createElement()', function() {
562
instance = ReactTestUtils.renderIntoDocument(<Parent/>);
563
});
564
565
- it('should scry children but cannot', function() {
565
+ it('should scry children but cannot', () => {
566
var children = ReactTestUtils.scryRenderedComponentsWithType(instance, Child);
567
expect(children.length).toBe(1);
568
});
569
570
- it('does not maintain refs', function() {
570
+ it('does not maintain refs', () => {
571
expect(instance.refs.child).not.toBeUndefined();
572
});
573
574
- it('can capture Child instantiation calls', function() {
574
+ it('can capture Child instantiation calls', () => {
575
expect(Child.mock.calls[0][0]).toEqual({ foo: 'foo value', children: 'children value' });
576
});
577
});
578
579
- describe('when using parent that uses .createFactory()', function() {
579
+ describe('when using parent that uses .createFactory()', () => {
580
var factory, instance;
581
- beforeEach(function() {
581
+ beforeEach(() => {
582
var childFactory = React.createFactory(Child);
583
var Parent = React.createClass({
584
render: function() {
@@ -589,23 +589,23 @@ describe('comparing jsx vs .createFactory() vs .createElement()', function() {
589
instance = ReactTestUtils.renderIntoDocument(factory());
590
});
591
592
- it('can properly scry children', function() {
592
+ it('can properly scry children', () => {
593
var children = ReactTestUtils.scryRenderedComponentsWithType(instance, Child);
594
expect(children.length).toBe(1);
595
});
596
597
- it('does not maintain refs', function() {
597
+ it('does not maintain refs', () => {
598
expect(instance.refs.child).not.toBeUndefined();
599
});
600
601
- it('can capture Child instantiation calls', function() {
601
+ it('can capture Child instantiation calls', () => {
602
expect(Child.mock.calls[0][0]).toEqual({ foo: 'foo value', children: 'children value' });
603
});
604
});
605
606
- describe('when using parent that uses .createElement()', function() {
606
+ describe('when using parent that uses .createElement()', () => {
607
var factory, instance;
608
- beforeEach(function() {
608
+ beforeEach(() => {
609
var Parent = React.createClass({
610
render: function() {
611
return React.DOM.div({}, React.createElement(Child, { ref: 'child', foo: 'foo value' }, 'children value'));
@@ -615,16 +615,16 @@ describe('comparing jsx vs .createFactory() vs .createElement()', function() {
615
instance = ReactTestUtils.renderIntoDocument(factory());
616
});
617
618
- it('should scry children but cannot', function() {
618
+ it('should scry children but cannot', () => {
619
var children = ReactTestUtils.scryRenderedComponentsWithType(instance, Child);
620
expect(children.length).toBe(1);
621
});
622
623
- it('does not maintain refs', function() {
623
+ it('does not maintain refs', () => {
624
expect(instance.refs.child).not.toBeUndefined();
625
});
626
627
- it('can capture Child instantiation calls', function() {
627
+ it('can capture Child instantiation calls', () => {
628
expect(Child.mock.calls[0][0]).toEqual({ foo: 'foo value', children: 'children value' });
629
});
630
});
src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
+24
-24
@@ -15,10 +15,10 @@ var React;
15
var ReactDOM;
16
var ReactTestUtils;
17
18
-describe('ReactElementClone', function() {
18
+describe('ReactElementClone', () => {
19
var ComponentClass;
20
21
- beforeEach(function() {
21
+ beforeEach(() => {
22
React = require('React');
23
ReactDOM = require('ReactDOM');
24
ReactTestUtils = require('ReactTestUtils');
@@ -32,7 +32,7 @@ describe('ReactElementClone', function() {
32
});
33
});
34
35
- it('should clone a DOM component with new props', function() {
35
+ it('should clone a DOM component with new props', () => {
36
var Grandparent = React.createClass({
37
render: function() {
38
return <Parent child={<div className="child" />} />;
@@ -51,7 +51,7 @@ describe('ReactElementClone', function() {
51
expect(ReactDOM.findDOMNode(component).childNodes[0].className).toBe('xyz');
52
});
53
54
- it('should clone a composite component with new props', function() {
54
+ it('should clone a composite component with new props', () => {
55
var Child = React.createClass({
56
render: function() {
57
return <div className={this.props.className} />;
@@ -75,7 +75,7 @@ describe('ReactElementClone', function() {
75
expect(ReactDOM.findDOMNode(component).childNodes[0].className).toBe('xyz');
76
});
77
78
- it('should warn if the config object inherits from any type other than Object', function() {
78
+ it('should warn if the config object inherits from any type other than Object', () => {
79
spyOn(console, 'error');
80
React.cloneElement('div', {foo: 1});
81
expect(console.error).not.toHaveBeenCalled();
@@ -87,12 +87,12 @@ describe('ReactElementClone', function() {
87
);
88
});
89
90
- it('does not fail if config has no prototype', function() {
90
+ it('does not fail if config has no prototype', () => {
91
var config = Object.create(null, {foo: {value: 1, enumerable: true}});
92
React.cloneElement(<div />, config);
93
});
94
95
- it('should keep the original ref if it is not overridden', function() {
95
+ it('should keep the original ref if it is not overridden', () => {
96
var Grandparent = React.createClass({
97
render: function() {
98
return <Parent child={<div ref="yolo" />} />;
@@ -113,7 +113,7 @@ describe('ReactElementClone', function() {
113
expect(component.refs.yolo.tagName).toBe('DIV');
114
});
115
116
- it('should transfer the key property', function() {
116
+ it('should transfer the key property', () => {
117
var Component = React.createClass({
118
render: function() {
119
return null;
@@ -123,7 +123,7 @@ describe('ReactElementClone', function() {
123
expect(clone.key).toBe('xyz');
124
});
125
126
- it('should transfer children', function() {
126
+ it('should transfer children', () => {
127
var Component = React.createClass({
128
render: function() {
129
expect(this.props.children).toBe('xyz');
@@ -136,7 +136,7 @@ describe('ReactElementClone', function() {
136
);
137
});
138
139
- it('should shallow clone children', function() {
139
+ it('should shallow clone children', () => {
140
var Component = React.createClass({
141
render: function() {
142
expect(this.props.children).toBe('xyz');
@@ -149,7 +149,7 @@ describe('ReactElementClone', function() {
149
);
150
});
151
152
- it('should accept children as rest arguments', function() {
152
+ it('should accept children as rest arguments', () => {
153
var Component = React.createClass({
154
render: function() {
155
return null;
@@ -169,7 +169,7 @@ describe('ReactElementClone', function() {
169
]);
170
});
171
172
- it('should override children if undefined is provided as an argument', function() {
172
+ it('should override children if undefined is provided as an argument', () => {
173
var element = React.createElement(ComponentClass, {
174
children: 'text',
175
}, undefined);
@@ -181,7 +181,7 @@ describe('ReactElementClone', function() {
181
expect(element2.props.children).toBe(undefined);
182
});
183
184
- it('should support keys and refs', function() {
184
+ it('should support keys and refs', () => {
185
var Parent = React.createClass({
186
render: function() {
187
var clone =
@@ -202,7 +202,7 @@ describe('ReactElementClone', function() {
202
expect(component.refs.parent.refs.xyz.tagName).toBe('SPAN');
203
});
204
205
- it('should steal the ref if a new ref is specified', function() {
205
+ it('should steal the ref if a new ref is specified', () => {
206
var Parent = React.createClass({
207
render: function() {
208
var clone = React.cloneElement(this.props.children, {ref: 'xyz'});
@@ -221,7 +221,7 @@ describe('ReactElementClone', function() {
221
expect(component.refs.parent.refs.xyz.tagName).toBe('SPAN');
222
});
223
224
- it('should overwrite props', function() {
224
+ it('should overwrite props', () => {
225
var Component = React.createClass({
226
render: function() {
227
expect(this.props.myprop).toBe('xyz');
@@ -234,7 +234,7 @@ describe('ReactElementClone', function() {
234
);
235
});
236
237
- it('should normalize props with default values', function() {
237
+ it('should normalize props with default values', () => {
238
var Component = React.createClass({
239
getDefaultProps: function() {
240
return {prop: 'testKey'};
@@ -257,7 +257,7 @@ describe('ReactElementClone', function() {
257
expect(cloneInstance4.props.prop).toBe('newTestKey');
258
});
259
260
- it('warns for keys for arrays of elements in rest args', function() {
260
+ it('warns for keys for arrays of elements in rest args', () => {
261
spyOn(console, 'error');
262
263
React.cloneElement(<div />, null, [<div />, <div />]);
@@ -268,7 +268,7 @@ describe('ReactElementClone', function() {
268
);
269
});
270
271
- it('does not warns for arrays of elements with keys', function() {
271
+ it('does not warns for arrays of elements with keys', () => {
272
spyOn(console, 'error');
273
274
React.cloneElement(<div />, null, [<div key="#1" />, <div key="#2" />]);
@@ -276,7 +276,7 @@ describe('ReactElementClone', function() {
276
expect(console.error.calls.count()).toBe(0);
277
});
278
279
- it('does not warn when the element is directly in rest args', function() {
279
+ it('does not warn when the element is directly in rest args', () => {
280
spyOn(console, 'error');
281
282
React.cloneElement(<div />, null, <div />, <div />);
@@ -284,7 +284,7 @@ describe('ReactElementClone', function() {
284
expect(console.error.calls.count()).toBe(0);
285
});
286
287
- it('does not warn when the array contains a non-element', function() {
287
+ it('does not warn when the array contains a non-element', () => {
288
spyOn(console, 'error');
289
290
React.cloneElement(<div />, null, [{}, {}]);
@@ -292,7 +292,7 @@ describe('ReactElementClone', function() {
292
expect(console.error.calls.count()).toBe(0);
293
});
294
295
- it('should check declared prop types after clone', function() {
295
+ it('should check declared prop types after clone', () => {
296
spyOn(console, 'error');
297
var Component = React.createClass({
298
propTypes: {
@@ -327,14 +327,14 @@ describe('ReactElementClone', function() {
327
);
328
});
329
330
- it('should ignore key and ref warning getters', function() {
330
+ it('should ignore key and ref warning getters', () => {
331
var elementA = React.createElement('div');
332
var elementB = React.cloneElement(elementA, elementA.props);
333
expect(elementB.key).toBe(null);
334
expect(elementB.ref).toBe(null);
335
});
336
337
- it('should ignore undefined key and ref', function() {
337
+ it('should ignore undefined key and ref', () => {
338
var element = React.createFactory(ComponentClass)({
339
key: '12',
340
ref: '34',
@@ -354,7 +354,7 @@ describe('ReactElementClone', function() {
354
expect(clone.props).toEqual({foo: 'ef'});
355
});
356
357
- it('should extract null key and ref', function() {
357
+ it('should extract null key and ref', () => {
358
var element = React.createFactory(ComponentClass)({
359
key: '12',
360
ref: '34',
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
+24
-24
@@ -18,14 +18,14 @@ var React;
18
var ReactDOM;
19
var ReactTestUtils;
20
21
-describe('ReactElementValidator', function() {
21
+describe('ReactElementValidator', () => {
22
function normalizeCodeLocInfo(str) {
23
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
24
}
25
26
var ComponentClass;
27
28
- beforeEach(function() {
28
+ beforeEach(() => {
29
jest.resetModuleRegistry();
30
31
React = require('React');
@@ -38,7 +38,7 @@ describe('ReactElementValidator', function() {
38
});
39
});
40
41
- it('warns for keys for arrays of elements in rest args', function() {
41
+ it('warns for keys for arrays of elements in rest args', () => {
42
spyOn(console, 'error');
43
var Component = React.createFactory(ComponentClass);
44
@@ -50,7 +50,7 @@ describe('ReactElementValidator', function() {
50
);
51
});
52
53
- it('warns for keys for arrays of elements with owner info', function() {
53
+ it('warns for keys for arrays of elements with owner info', () => {
54
spyOn(console, 'error');
55
var Component = React.createFactory(ComponentClass);
56
@@ -82,7 +82,7 @@ describe('ReactElementValidator', function() {
82
);
83
});
84
85
- it('warns for keys for arrays with no owner or parent info', function() {
85
+ it('warns for keys for arrays with no owner or parent info', () => {
86
spyOn(console, 'error');
87
88
var Anonymous = React.createClass({
@@ -106,7 +106,7 @@ describe('ReactElementValidator', function() {
106
);
107
});
108
109
- it('warns for keys for arrays of elements with no owner info', function() {
109
+ it('warns for keys for arrays of elements with no owner info', () => {
110
spyOn(console, 'error');
111
112
var divs = [
@@ -124,7 +124,7 @@ describe('ReactElementValidator', function() {
124
);
125
});
126
127
- it('warns for keys with component stack info', function() {
127
+ it('warns for keys with component stack info', () => {
128
spyOn(console, 'error');
129
130
var Component = React.createClass({
@@ -159,7 +159,7 @@ describe('ReactElementValidator', function() {
159
);
160
});
161
162
- it('does not warn for keys when passing children down', function() {
162
+ it('does not warn for keys when passing children down', () => {
163
spyOn(console, 'error');
164
165
var Wrapper = React.createClass({
@@ -183,7 +183,7 @@ describe('ReactElementValidator', function() {
183
expect(console.error.calls.count()).toBe(0);
184
});
185
186
- it('warns for keys for iterables of elements in rest args', function() {
186
+ it('warns for keys for iterables of elements in rest args', () => {
187
spyOn(console, 'error');
188
var Component = React.createFactory(ComponentClass);
189
@@ -207,7 +207,7 @@ describe('ReactElementValidator', function() {
207
);
208
});
209
210
- it('does not warns for arrays of elements with keys', function() {
210
+ it('does not warns for arrays of elements with keys', () => {
211
spyOn(console, 'error');
212
var Component = React.createFactory(ComponentClass);
213
@@ -216,7 +216,7 @@ describe('ReactElementValidator', function() {
216
expect(console.error.calls.count()).toBe(0);
217
});
218
219
- it('does not warns for iterable elements with keys', function() {
219
+ it('does not warns for iterable elements with keys', () => {
220
spyOn(console, 'error');
221
var Component = React.createFactory(ComponentClass);
222
@@ -240,7 +240,7 @@ describe('ReactElementValidator', function() {
240
expect(console.error.calls.count()).toBe(0);
241
});
242
243
- it('does not warn when the element is directly in rest args', function() {
243
+ it('does not warn when the element is directly in rest args', () => {
244
spyOn(console, 'error');
245
var Component = React.createFactory(ComponentClass);
246
@@ -249,7 +249,7 @@ describe('ReactElementValidator', function() {
249
expect(console.error.calls.count()).toBe(0);
250
});
251
252
- it('does not warn when the array contains a non-element', function() {
252
+ it('does not warn when the array contains a non-element', () => {
253
spyOn(console, 'error');
254
var Component = React.createFactory(ComponentClass);
255
@@ -289,7 +289,7 @@ describe('ReactElementValidator', function() {
289
);
290
});
291
292
- it('gives a helpful error when passing null, undefined, boolean, or number', function() {
292
+ it('gives a helpful error when passing null, undefined, boolean, or number', () => {
293
spyOn(console, 'error');
294
React.createElement(undefined);
295
React.createElement(null);
@@ -320,7 +320,7 @@ describe('ReactElementValidator', function() {
320
expect(console.error.calls.count()).toBe(4);
321
});
322
323
- it('includes the owner name when passing null, undefined, boolean, or number', function() {
323
+ it('includes the owner name when passing null, undefined, boolean, or number', () => {
324
spyOn(console, 'error');
325
var ParentComp = React.createClass({
326
render: function() {
@@ -343,7 +343,7 @@ describe('ReactElementValidator', function() {
343
);
344
});
345
346
- it('should check default prop values', function() {
346
+ it('should check default prop values', () => {
347
spyOn(console, 'error');
348
349
var Component = React.createClass({
@@ -366,7 +366,7 @@ describe('ReactElementValidator', function() {
366
);
367
});
368
369
- it('should not check the default for explicit null', function() {
369
+ it('should not check the default for explicit null', () => {
370
spyOn(console, 'error');
371
372
var Component = React.createClass({
@@ -391,7 +391,7 @@ describe('ReactElementValidator', function() {
391
);
392
});
393
394
- it('should check declared prop types', function() {
394
+ it('should check declared prop types', () => {
395
spyOn(console, 'error');
396
397
var Component = React.createClass({
@@ -433,7 +433,7 @@ describe('ReactElementValidator', function() {
433
expect(console.error.calls.count()).toBe(2);
434
});
435
436
- it('should warn if a PropType creator is used as a PropType', function() {
436
+ it('should warn if a PropType creator is used as a PropType', () => {
437
spyOn(console, 'error');
438
439
var Component = React.createClass({
@@ -459,7 +459,7 @@ describe('ReactElementValidator', function() {
459
);
460
});
461
462
- it('should warn when accessing .type on an element factory', function() {
462
+ it('should warn when accessing .type on an element factory', () => {
463
spyOn(console, 'error');
464
var TestComponent = React.createClass({
465
render: function() {
@@ -478,7 +478,7 @@ describe('ReactElementValidator', function() {
478
expect(console.error.calls.count()).toBe(1);
479
});
480
481
- it('does not warn when using DOM node as children', function() {
481
+ it('does not warn when using DOM node as children', () => {
482
spyOn(console, 'error');
483
var DOMContainer = React.createClass({
484
render: function() {
@@ -495,7 +495,7 @@ describe('ReactElementValidator', function() {
495
expect(console.error.calls.count()).toBe(0);
496
});
497
498
- it('should not enumerate enumerable numbers (#4776)', function() {
498
+ it('should not enumerate enumerable numbers (#4776)', () => {
499
/*eslint-disable no-extend-native */
500
Number.prototype['@@iterator'] = function() {
501
throw new Error('number iterator called');
@@ -515,7 +515,7 @@ describe('ReactElementValidator', function() {
515
}
516
});
517
518
- it('does not blow up with inlined children', function() {
518
+ it('does not blow up with inlined children', () => {
519
// We don't suggest this since it silences all sorts of warnings, but we
520
// shouldn't blow up either.
521
@@ -531,7 +531,7 @@ describe('ReactElementValidator', function() {
531
void <div>{[child]}</div>;
532
});
533
534
- it('does not blow up on key warning with undefined type', function() {
534
+ it('does not blow up on key warning with undefined type', () => {
535
spyOn(console, 'error');
536
var Foo = undefined;
537
void <Foo>{[<div />]}</Foo>;
src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
+92
-92
@@ -106,8 +106,8 @@ function expectWarningInDevelopment(declaration, value) {
106
console.error.calls.reset();
107
}
108
109
-describe('ReactPropTypes', function() {
110
- beforeEach(function() {
109
+describe('ReactPropTypes', () => {
110
+ beforeEach(() => {
111
PropTypes = require('ReactPropTypes');
112
React = require('React');
113
ReactFragment = require('ReactFragment');
@@ -115,8 +115,8 @@ describe('ReactPropTypes', function() {
115
ReactPropTypesSecret = require('ReactPropTypesSecret');
116
});
117
118
- describe('Primitive Types', function() {
119
- it('should warn for invalid strings', function() {
118
+ describe('Primitive Types', () => {
119
+ it('should warn for invalid strings', () => {
120
typeCheckFail(
121
PropTypes.string,
122
[],
@@ -149,7 +149,7 @@ describe('ReactPropTypes', function() {
149
);
150
});
151
152
- it('should fail date and regexp correctly', function() {
152
+ it('should fail date and regexp correctly', () => {
153
typeCheckFail(
154
PropTypes.string,
155
new Date(),
@@ -164,7 +164,7 @@ describe('ReactPropTypes', function() {
164
);
165
});
166
167
- it('should not warn for valid values', function() {
167
+ it('should not warn for valid values', () => {
168
typeCheckPass(PropTypes.array, []);
169
typeCheckPass(PropTypes.bool, false);
170
typeCheckPass(PropTypes.func, function() {});
@@ -176,16 +176,16 @@ describe('ReactPropTypes', function() {
176
typeCheckPass(PropTypes.symbol, Symbol());
177
});
178
179
- it('should be implicitly optional and not warn without values', function() {
179
+ it('should be implicitly optional and not warn without values', () => {
180
typeCheckPass(PropTypes.string, null);
181
typeCheckPass(PropTypes.string, undefined);
182
});
183
184
- it('should warn for missing required values', function() {
184
+ it('should warn for missing required values', () => {
185
typeCheckFailRequiredValues(PropTypes.string.isRequired);
186
});
187
188
- it('should warn if called manually in development', function() {
188
+ it('should warn if called manually in development', () => {
189
spyOn(console, 'error');
190
expectWarningInDevelopment(PropTypes.array, /please/);
191
expectWarningInDevelopment(PropTypes.array, []);
@@ -232,24 +232,24 @@ describe('ReactPropTypes', function() {
232
});
233
});
234
235
- describe('Any type', function() {
236
- it('should should accept any value', function() {
235
+ describe('Any type', () => {
236
+ it('should should accept any value', () => {
237
typeCheckPass(PropTypes.any, 0);
238
typeCheckPass(PropTypes.any, 'str');
239
typeCheckPass(PropTypes.any, []);
240
typeCheckPass(PropTypes.any, Symbol());
241
});
242
243
- it('should be implicitly optional and not warn without values', function() {
243
+ it('should be implicitly optional and not warn without values', () => {
244
typeCheckPass(PropTypes.any, null);
245
typeCheckPass(PropTypes.any, undefined);
246
});
247
248
- it('should warn for missing required values', function() {
248
+ it('should warn for missing required values', () => {
249
typeCheckFailRequiredValues(PropTypes.any.isRequired);
250
});
251
252
- it('should warn if called manually in development', function() {
252
+ it('should warn if called manually in development', () => {
253
spyOn(console, 'error');
254
expectWarningInDevelopment(PropTypes.any, null);
255
expectWarningInDevelopment(PropTypes.any.isRequired, null);
@@ -257,8 +257,8 @@ describe('ReactPropTypes', function() {
257
});
258
});
259
260
- describe('ArrayOf Type', function() {
261
- it('should fail for invalid argument', function() {
260
+ describe('ArrayOf Type', () => {
261
+ it('should fail for invalid argument', () => {
262
typeCheckFail(
263
PropTypes.arrayOf({ foo: PropTypes.string }),
264
{ foo: 'bar' },
@@ -266,14 +266,14 @@ describe('ReactPropTypes', function() {
266
);
267
});
268
269
- it('should support the arrayOf propTypes', function() {
269
+ it('should support the arrayOf propTypes', () => {
270
typeCheckPass(PropTypes.arrayOf(PropTypes.number), [1, 2, 3]);
271
typeCheckPass(PropTypes.arrayOf(PropTypes.string), ['a', 'b', 'c']);
272
typeCheckPass(PropTypes.arrayOf(PropTypes.oneOf(['a', 'b'])), ['a', 'b']);
273
typeCheckPass(PropTypes.arrayOf(PropTypes.symbol), [Symbol(), Symbol()]);
274
});
275
276
- it('should support arrayOf with complex types', function() {
276
+ it('should support arrayOf with complex types', () => {
277
typeCheckPass(
278
PropTypes.arrayOf(PropTypes.shape({a: PropTypes.number.isRequired})),
279
[{a: 1}, {a: 2}]
@@ -286,7 +286,7 @@ describe('ReactPropTypes', function() {
286
);
287
});
288
289
- it('should warn with invalid items in the array', function() {
289
+ it('should warn with invalid items in the array', () => {
290
typeCheckFail(
291
PropTypes.arrayOf(PropTypes.number),
292
[1, 2, 'b'],
@@ -295,7 +295,7 @@ describe('ReactPropTypes', function() {
295
);
296
});
297
298
- it('should warn with invalid complex types', function() {
298
+ it('should warn with invalid complex types', () => {
299
function Thing() {}
300
var name = Thing.name || '<<anonymous>>';
301
@@ -307,7 +307,7 @@ describe('ReactPropTypes', function() {
307
);
308
});
309
310
- it('should warn when passed something other than an array', function() {
310
+ it('should warn when passed something other than an array', () => {
311
typeCheckFail(
312
PropTypes.arrayOf(PropTypes.number),
313
{'0': 'maybe-array', length: 1},
@@ -328,22 +328,22 @@ describe('ReactPropTypes', function() {
328
);
329
});
330
331
- it('should not warn when passing an empty array', function() {
331
+ it('should not warn when passing an empty array', () => {
332
typeCheckPass(PropTypes.arrayOf(PropTypes.number), []);
333
});
334
335
- it('should be implicitly optional and not warn without values', function() {
335
+ it('should be implicitly optional and not warn without values', () => {
336
typeCheckPass(PropTypes.arrayOf(PropTypes.number), null);
337
typeCheckPass(PropTypes.arrayOf(PropTypes.number), undefined);
338
});
339
340
- it('should warn for missing required values', function() {
340
+ it('should warn for missing required values', () => {
341
typeCheckFailRequiredValues(
342
PropTypes.arrayOf(PropTypes.number).isRequired
343
);
344
});
345
346
- it('should warn if called manually in development', function() {
346
+ it('should warn if called manually in development', () => {
347
spyOn(console, 'error');
348
expectWarningInDevelopment(
349
PropTypes.arrayOf({ foo: PropTypes.string }),
@@ -362,8 +362,8 @@ describe('ReactPropTypes', function() {
362
});
363
});
364
365
- describe('Component Type', function() {
366
- beforeEach(function() {
365
+ describe('Component Type', () => {
366
+ beforeEach(() => {
367
Component = class extends React.Component {
368
static propTypes = {
369
label: PropTypes.element.isRequired,
@@ -424,16 +424,16 @@ describe('ReactPropTypes', function() {
424
expect(console.error.calls.count()).toBe(1);
425
});
426
427
- it('should be implicitly optional and not warn without values', function() {
427
+ it('should be implicitly optional and not warn without values', () => {
428
typeCheckPass(PropTypes.element, null);
429
typeCheckPass(PropTypes.element, undefined);
430
});
431
432
- it('should warn for missing required values', function() {
432
+ it('should warn for missing required values', () => {
433
typeCheckFailRequiredValues(PropTypes.element.isRequired);
434
});
435
436
- it('should warn if called manually in development', function() {
436
+ it('should warn if called manually in development', () => {
437
spyOn(console, 'error');
438
expectWarningInDevelopment(PropTypes.element, [<div />, <div />]);
439
expectWarningInDevelopment(PropTypes.element, <div />);
@@ -446,8 +446,8 @@ describe('ReactPropTypes', function() {
446
447
});
448
449
- describe('Instance Types', function() {
450
- it('should warn for invalid instances', function() {
449
+ describe('Instance Types', () => {
450
+ it('should warn for invalid instances', () => {
451
function Person() {}
452
function Cat() {}
453
var personName = Person.name || '<<anonymous>>';
@@ -498,7 +498,7 @@ describe('ReactPropTypes', function() {
498
);
499
});
500
501
- it('should not warn for valid values', function() {
501
+ it('should not warn for valid values', () => {
502
function Person() {}
503
function Engineer() {}
504
Engineer.prototype = new Person();
@@ -510,16 +510,16 @@ describe('ReactPropTypes', function() {
510
typeCheckPass(PropTypes.instanceOf(RegExp), /please/);
511
});
512
513
- it('should be implicitly optional and not warn without values', function() {
513
+ it('should be implicitly optional and not warn without values', () => {
514
typeCheckPass(PropTypes.instanceOf(String), null);
515
typeCheckPass(PropTypes.instanceOf(String), undefined);
516
});
517
518
- it('should warn for missing required values', function() {
518
+ it('should warn for missing required values', () => {
519
typeCheckFailRequiredValues(PropTypes.instanceOf(String).isRequired);
520
});
521
522
- it('should warn if called manually in development', function() {
522
+ it('should warn if called manually in development', () => {
523
spyOn(console, 'error');
524
expectWarningInDevelopment(PropTypes.instanceOf(Date), {});
525
expectWarningInDevelopment(PropTypes.instanceOf(Date), new Date());
@@ -529,8 +529,8 @@ describe('ReactPropTypes', function() {
529
530
});
531
532
- describe('React Component Types', function() {
533
- beforeEach(function() {
532
+ describe('React Component Types', () => {
533
+ beforeEach(() => {
534
MyComponent = class extends React.Component {
535
render() {
536
return <div />;
@@ -538,7 +538,7 @@ describe('ReactPropTypes', function() {
538
};
539
});
540
541
- it('should warn for invalid values', function() {
541
+ it('should warn for invalid values', () => {
542
var failMessage = 'Invalid prop `testProp` supplied to ' +
543
'`testComponent`, expected a ReactNode.';
544
typeCheckFail(PropTypes.node, true, failMessage);
@@ -547,7 +547,7 @@ describe('ReactPropTypes', function() {
547
typeCheckFail(PropTypes.node, {key: <div />}, failMessage);
548
});
549
550
- it('should not warn for valid values', function() {
550
+ it('should not warn for valid values', () => {
551
spyOn(console, 'error');
552
typeCheckPass(PropTypes.node, <div />);
553
typeCheckPass(PropTypes.node, false);
@@ -580,7 +580,7 @@ describe('ReactPropTypes', function() {
580
expect(console.error.calls.count()).toBe(0);
581
});
582
583
- it('should not warn for iterables', function() {
583
+ it('should not warn for iterables', () => {
584
var iterable = {
585
'@@iterator': function() {
586
var i = 0;
@@ -596,7 +596,7 @@ describe('ReactPropTypes', function() {
596
typeCheckPass(PropTypes.node, iterable);
597
});
598
599
- it('should not warn for entry iterables', function() {
599
+ it('should not warn for entry iterables', () => {
600
var iterable = {
601
'@@iterator': function() {
602
var i = 0;
@@ -613,20 +613,20 @@ describe('ReactPropTypes', function() {
613
typeCheckPass(PropTypes.node, iterable);
614
});
615
616
- it('should not warn for null/undefined if not required', function() {
616
+ it('should not warn for null/undefined if not required', () => {
617
typeCheckPass(PropTypes.node, null);
618
typeCheckPass(PropTypes.node, undefined);
619
});
620
621
- it('should warn for missing required values', function() {
621
+ it('should warn for missing required values', () => {
622
typeCheckFailRequiredValues(PropTypes.node.isRequired);
623
});
624
625
- it('should accept empty array for required props', function() {
625
+ it('should accept empty array for required props', () => {
626
typeCheckPass(PropTypes.node.isRequired, []);
627
});
628
629
- it('should warn if called manually in development', function() {
629
+ it('should warn if called manually in development', () => {
630
spyOn(console, 'error');
631
expectWarningInDevelopment(PropTypes.node, 'node');
632
expectWarningInDevelopment(PropTypes.node, {});
@@ -637,8 +637,8 @@ describe('ReactPropTypes', function() {
637
638
});
639
640
- describe('ObjectOf Type', function() {
641
- it('should fail for invalid argument', function() {
640
+ describe('ObjectOf Type', () => {
641
+ it('should fail for invalid argument', () => {
642
typeCheckFail(
643
PropTypes.objectOf({ foo: PropTypes.string }),
644
{ foo: 'bar' },
@@ -646,7 +646,7 @@ describe('ReactPropTypes', function() {
646
);
647
});
648
649
- it('should support the objectOf propTypes', function() {
649
+ it('should support the objectOf propTypes', () => {
650
typeCheckPass(PropTypes.objectOf(PropTypes.number), {a: 1, b: 2, c: 3});
651
typeCheckPass(
652
PropTypes.objectOf(PropTypes.string),
@@ -662,7 +662,7 @@ describe('ReactPropTypes', function() {
662
);
663
});
664
665
- it('should support objectOf with complex types', function() {
665
+ it('should support objectOf with complex types', () => {
666
typeCheckPass(
667
PropTypes.objectOf(PropTypes.shape({a: PropTypes.number.isRequired})),
668
{a: {a: 1}, b: {a: 2}}
@@ -675,7 +675,7 @@ describe('ReactPropTypes', function() {
675
);
676
});
677
678
- it('should warn with invalid items in the object', function() {
678
+ it('should warn with invalid items in the object', () => {
679
typeCheckFail(
680
PropTypes.objectOf(PropTypes.number),
681
{a: 1, b: 2, c: 'b'},
@@ -684,7 +684,7 @@ describe('ReactPropTypes', function() {
684
);
685
});
686
687
- it('should warn with invalid complex types', function() {
687
+ it('should warn with invalid complex types', () => {
688
function Thing() {}
689
var name = Thing.name || '<<anonymous>>';
690
@@ -696,7 +696,7 @@ describe('ReactPropTypes', function() {
696
);
697
});
698
699
- it('should warn when passed something other than an object', function() {
699
+ it('should warn when passed something other than an object', () => {
700
typeCheckFail(
701
PropTypes.objectOf(PropTypes.number),
702
[1, 2],
@@ -723,22 +723,22 @@ describe('ReactPropTypes', function() {
723
);
724
});
725
726
- it('should not warn when passing an empty object', function() {
726
+ it('should not warn when passing an empty object', () => {
727
typeCheckPass(PropTypes.objectOf(PropTypes.number), {});
728
});
729
730
- it('should be implicitly optional and not warn without values', function() {
730
+ it('should be implicitly optional and not warn without values', () => {
731
typeCheckPass(PropTypes.objectOf(PropTypes.number), null);
732
typeCheckPass(PropTypes.objectOf(PropTypes.number), undefined);
733
});
734
735
- it('should warn for missing required values', function() {
735
+ it('should warn for missing required values', () => {
736
typeCheckFailRequiredValues(
737
PropTypes.objectOf(PropTypes.number).isRequired
738
);
739
});
740
741
- it('should warn if called manually in development', function() {
741
+ it('should warn if called manually in development', () => {
742
spyOn(console, 'error');
743
expectWarningInDevelopment(
744
PropTypes.objectOf({ foo: PropTypes.string }),
@@ -754,8 +754,8 @@ describe('ReactPropTypes', function() {
754
});
755
});
756
757
- describe('OneOf Types', function() {
758
- it('should warn but not error for invalid argument', function() {
757
+ describe('OneOf Types', () => {
758
+ it('should warn but not error for invalid argument', () => {
759
spyOn(console, 'error');
760
761
PropTypes.oneOf('red', 'blue');
@@ -767,7 +767,7 @@ describe('ReactPropTypes', function() {
767
typeCheckPass(PropTypes.oneOf('red', 'blue'), 'red');
768
});
769
770
- it('should warn for invalid values', function() {
770
+ it('should warn for invalid values', () => {
771
typeCheckFail(
772
PropTypes.oneOf(['red', 'blue']),
773
true,
@@ -794,22 +794,22 @@ describe('ReactPropTypes', function() {
794
);
795
});
796
797
- it('should not warn for valid values', function() {
797
+ it('should not warn for valid values', () => {
798
typeCheckPass(PropTypes.oneOf(['red', 'blue']), 'red');
799
typeCheckPass(PropTypes.oneOf(['red', 'blue']), 'blue');
800
typeCheckPass(PropTypes.oneOf(['red', 'blue', NaN]), NaN);
801
});
802
803
- it('should be implicitly optional and not warn without values', function() {
803
+ it('should be implicitly optional and not warn without values', () => {
804
typeCheckPass(PropTypes.oneOf(['red', 'blue']), null);
805
typeCheckPass(PropTypes.oneOf(['red', 'blue']), undefined);
806
});
807
808
- it('should warn for missing required values', function() {
808
+ it('should warn for missing required values', () => {
809
typeCheckFailRequiredValues(PropTypes.oneOf(['red', 'blue']).isRequired);
810
});
811
812
- it('should warn if called manually in development', function() {
812
+ it('should warn if called manually in development', () => {
813
spyOn(console, 'error');
814
expectWarningInDevelopment(PropTypes.oneOf(['red', 'blue']), true);
815
expectWarningInDevelopment(PropTypes.oneOf(['red', 'blue']), null);
@@ -817,8 +817,8 @@ describe('ReactPropTypes', function() {
817
});
818
});
819
820
- describe('Union Types', function() {
821
- it('should warn but not error for invalid argument', function() {
820
+ describe('Union Types', () => {
821
+ it('should warn but not error for invalid argument', () => {
822
spyOn(console, 'error');
823
824
PropTypes.oneOfType(PropTypes.string, PropTypes.number);
@@ -830,7 +830,7 @@ describe('ReactPropTypes', function() {
830
typeCheckPass(PropTypes.oneOf(PropTypes.string, PropTypes.number), []);
831
});
832
833
- it('should warn if none of the types are valid', function() {
833
+ it('should warn if none of the types are valid', () => {
834
typeCheckFail(
835
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
836
[],
@@ -848,7 +848,7 @@ describe('ReactPropTypes', function() {
848
);
849
});
850
851
- it('should not warn if one of the types are valid', function() {
851
+ it('should not warn if one of the types are valid', () => {
852
var checker = PropTypes.oneOfType([
853
PropTypes.string,
854
PropTypes.number,
@@ -865,7 +865,7 @@ describe('ReactPropTypes', function() {
865
typeCheckPass(checker, {b: 1});
866
});
867
868
- it('should be implicitly optional and not warn without values', function() {
868
+ it('should be implicitly optional and not warn without values', () => {
869
typeCheckPass(
870
PropTypes.oneOfType([PropTypes.string, PropTypes.number]), null
871
);
@@ -874,13 +874,13 @@ describe('ReactPropTypes', function() {
874
);
875
});
876
877
- it('should warn for missing required values', function() {
877
+ it('should warn for missing required values', () => {
878
typeCheckFailRequiredValues(
879
PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
880
);
881
});
882
883
- it('should warn if called manually in development', function() {
883
+ it('should warn if called manually in development', () => {
884
spyOn(console, 'error');
885
expectWarningInDevelopment(
886
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
@@ -898,8 +898,8 @@ describe('ReactPropTypes', function() {
898
899
});
900
901
- describe('Shape Types', function() {
902
- it('should warn for non objects', function() {
901
+ describe('Shape Types', () => {
902
+ it('should warn for non objects', () => {
903
typeCheckFail(
904
PropTypes.shape({}),
905
'some string',
@@ -914,25 +914,25 @@ describe('ReactPropTypes', function() {
914
);
915
});
916
917
- it('should not warn for empty values', function() {
917
+ it('should not warn for empty values', () => {
918
typeCheckPass(PropTypes.shape({}), undefined);
919
typeCheckPass(PropTypes.shape({}), null);
920
typeCheckPass(PropTypes.shape({}), {});
921
});
922
923
- it('should not warn for an empty object', function() {
923
+ it('should not warn for an empty object', () => {
924
typeCheckPass(PropTypes.shape({}).isRequired, {});
925
});
926
927
- it('should not warn for non specified types', function() {
927
+ it('should not warn for non specified types', () => {
928
typeCheckPass(PropTypes.shape({}), {key: 1});
929
});
930
931
- it('should not warn for valid types', function() {
931
+ it('should not warn for valid types', () => {
932
typeCheckPass(PropTypes.shape({key: PropTypes.number}), {key: 1});
933
});
934
935
- it('should warn for required valid types', function() {
935
+ it('should warn for required valid types', () => {
936
typeCheckFail(
937
PropTypes.shape({key: PropTypes.number.isRequired}),
938
{},
@@ -941,7 +941,7 @@ describe('ReactPropTypes', function() {
941
);
942
});
943
944
- it('should warn for the first required type', function() {
944
+ it('should warn for the first required type', () => {
945
typeCheckFail(
946
PropTypes.shape({
947
key: PropTypes.number.isRequired,
@@ -953,7 +953,7 @@ describe('ReactPropTypes', function() {
953
);
954
});
955
956
- it('should warn for invalid key types', function() {
956
+ it('should warn for invalid key types', () => {
957
typeCheckFail(PropTypes.shape({key: PropTypes.number}),
958
{key: 'abc'},
959
'Invalid prop `testProp.key` of type `string` supplied to `testComponent`, ' +
@@ -961,7 +961,7 @@ describe('ReactPropTypes', function() {
961
);
962
});
963
964
- it('should be implicitly optional and not warn without values', function() {
964
+ it('should be implicitly optional and not warn without values', () => {
965
typeCheckPass(
966
PropTypes.shape(PropTypes.shape({key: PropTypes.number})), null
967
);
@@ -970,13 +970,13 @@ describe('ReactPropTypes', function() {
970
);
971
});
972
973
- it('should warn for missing required values', function() {
973
+ it('should warn for missing required values', () => {
974
typeCheckFailRequiredValues(
975
PropTypes.shape({key: PropTypes.number}).isRequired
976
);
977
});
978
979
- it('should warn if called manually in development', function() {
979
+ it('should warn if called manually in development', () => {
980
spyOn(console, 'error');
981
expectWarningInDevelopment(PropTypes.shape({}), 'some string');
982
expectWarningInDevelopment(PropTypes.shape({ foo: PropTypes.number }), { foo: 42 });
@@ -992,8 +992,8 @@ describe('ReactPropTypes', function() {
992
});
993
});
994
995
- describe('Symbol Type', function() {
996
- it('should warn for non-symbol', function() {
995
+ describe('Symbol Type', () => {
996
+ it('should warn for non-symbol', () => {
997
typeCheckFail(
998
PropTypes.symbol,
999
'hello',
@@ -1016,18 +1016,18 @@ describe('ReactPropTypes', function() {
1016
);
1017
});
1018
1019
- it('should not warn for a polyfilled Symbol', function() {
1019
+ it('should not warn for a polyfilled Symbol', () => {
1020
var CoreSymbol = require('core-js/library/es6/symbol');
1021
typeCheckPass(PropTypes.symbol, CoreSymbol('core-js'));
1022
});
1023
});
1024
1025
- describe('Custom validator', function() {
1026
- beforeEach(function() {
1025
+ describe('Custom validator', () => {
1026
+ beforeEach(() => {
1027
jest.resetModuleRegistry();
1028
});
1029
1030
- it('should have been called with the right params', function() {
1030
+ it('should have been called with the right params', () => {
1031
var spy = jasmine.createSpy();
1032
Component = class extends React.Component {
1033
static propTypes = {num: spy};
@@ -1044,7 +1044,7 @@ describe('ReactPropTypes', function() {
1044
expect(spy.calls.argsFor(0)[1]).toBe('num');
1045
});
1046
1047
- it('should have been called even if the prop is not present', function() {
1047
+ it('should have been called even if the prop is not present', () => {
1048
var spy = jasmine.createSpy();
1049
Component = class extends React.Component {
1050
static propTypes = {num: spy};
@@ -1061,7 +1061,7 @@ describe('ReactPropTypes', function() {
1061
expect(spy.calls.argsFor(0)[1]).toBe('num');
1062
});
1063
1064
- it('should have received the validator\'s return value', function() {
1064
+ it('should have received the validator\'s return value', () => {
1065
spyOn(console, 'error');
1066
var spy = jasmine.createSpy().and.callFake(
1067
function(props, propName, componentName) {
@@ -1090,7 +1090,7 @@ describe('ReactPropTypes', function() {
1090
});
1091
1092
it('should not warn if the validator returned null',
1093
- function() {
1093
+ () => {
1094
spyOn(console, 'error');
1095
var spy = jasmine.createSpy().and.callFake(
1096
function(props, propName, componentName) {
src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js
+3
-3
@@ -14,14 +14,14 @@
14
var spawnSync = require('child_process').spawnSync;
15
var path = require('path');
16
17
-describe('ReactClassEquivalence', function() {
18
- it('tests the same thing for es6 classes and CoffeeScript', function() {
17
+describe('ReactClassEquivalence', () => {
18
+ it('tests the same thing for es6 classes and CoffeeScript', () => {
19
var result1 = runJest('ReactCoffeeScriptClass-test.coffee');
20
var result2 = runJest('ReactES6Class-test.js');
21
compareResults(result1, result2);
22
});
23
24
- it('tests the same thing for es6 classes and TypeScript', function() {
24
+ it('tests the same thing for es6 classes and TypeScript', () => {
25
var result1 = runJest('ReactTypeScriptClass-test.ts');
26
var result2 = runJest('ReactES6Class-test.js');
27
compareResults(result1, result2);
src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
+22
-22
@@ -14,7 +14,7 @@
14
var React;
15
var ReactDOM;
16
17
-describe('ReactES6Class', function() {
17
+describe('ReactES6Class', () => {
18
19
var container;
20
var freeze = function(expectation) {
@@ -25,7 +25,7 @@ describe('ReactES6Class', function() {
25
var attachedListener = null;
26
var renderedName = null;
27
28
- beforeEach(function() {
28
+ beforeEach(() => {
29
React = require('React');
30
ReactDOM = require('ReactDOM');
31
container = document.createElement('div');
@@ -51,12 +51,12 @@ describe('ReactES6Class', function() {
51
return instance;
52
}
53
54
- it('preserves the name of the class for use in error messages', function() {
54
+ it('preserves the name of the class for use in error messages', () => {
55
class Foo extends React.Component { }
56
expect(Foo.name).toBe('Foo');
57
});
58
59
- it('throws if no render function is defined', function() {
59
+ it('throws if no render function is defined', () => {
60
spyOn(console, 'error');
61
class Foo extends React.Component { }
62
expect(() => ReactDOM.render(<Foo />, container)).toThrow();
@@ -68,7 +68,7 @@ describe('ReactES6Class', function() {
68
);
69
});
70
71
- it('renders a simple stateless component with prop', function() {
71
+ it('renders a simple stateless component with prop', () => {
72
class Foo extends React.Component {
73
render() {
74
return <Inner name={this.props.bar} />;
@@ -78,7 +78,7 @@ describe('ReactES6Class', function() {
78
test(<Foo bar="bar" />, 'DIV', 'bar');
79
});
80
81
- it('renders based on state using initial values in this.props', function() {
81
+ it('renders based on state using initial values in this.props', () => {
82
class Foo extends React.Component {
83
constructor(props) {
84
super(props);
@@ -91,7 +91,7 @@ describe('ReactES6Class', function() {
91
test(<Foo initialValue="foo" />, 'SPAN', 'foo');
92
});
93
94
- it('renders based on state using props in the constructor', function() {
94
+ it('renders based on state using props in the constructor', () => {
95
class Foo extends React.Component {
96
constructor(props) {
97
super(props);
@@ -112,7 +112,7 @@ describe('ReactES6Class', function() {
112
test(<Foo />, 'SPAN', 'bar');
113
});
114
115
- it('renders based on context in the constructor', function() {
115
+ it('renders based on context in the constructor', () => {
116
class Foo extends React.Component {
117
constructor(props, context) {
118
super(props, context);
@@ -143,7 +143,7 @@ describe('ReactES6Class', function() {
143
test(<Outer />, 'SPAN', 'foo');
144
});
145
146
- it('renders only once when setting state in componentWillMount', function() {
146
+ it('renders only once when setting state in componentWillMount', () => {
147
var renderCount = 0;
148
class Foo extends React.Component {
149
constructor(props) {
@@ -162,7 +162,7 @@ describe('ReactES6Class', function() {
162
expect(renderCount).toBe(1);
163
});
164
165
- it('should throw with non-object in the initial state property', function() {
165
+ it('should throw with non-object in the initial state property', () => {
166
[['an array'], 'a string', 1234].forEach(function(state) {
167
class Foo extends React.Component {
168
constructor() {
@@ -179,7 +179,7 @@ describe('ReactES6Class', function() {
179
});
180
});
181
182
- it('should render with null in the initial state property', function() {
182
+ it('should render with null in the initial state property', () => {
183
class Foo extends React.Component {
184
constructor() {
185
super();
@@ -192,7 +192,7 @@ describe('ReactES6Class', function() {
192
test(<Foo />, 'SPAN', '');
193
});
194
195
- it('setState through an event handler', function() {
195
+ it('setState through an event handler', () => {
196
class Foo extends React.Component {
197
constructor(props) {
198
super(props);
@@ -215,7 +215,7 @@ describe('ReactES6Class', function() {
215
expect(renderedName).toBe('bar');
216
});
217
218
- it('should not implicitly bind event handlers', function() {
218
+ it('should not implicitly bind event handlers', () => {
219
class Foo extends React.Component {
220
constructor(props) {
221
super(props);
@@ -237,7 +237,7 @@ describe('ReactES6Class', function() {
237
expect(attachedListener).toThrow();
238
});
239
240
- it('renders using forceUpdate even when there is no state', function() {
240
+ it('renders using forceUpdate even when there is no state', () => {
241
class Foo extends React.Component {
242
constructor(props) {
243
super(props);
@@ -261,7 +261,7 @@ describe('ReactES6Class', function() {
261
expect(renderedName).toBe('bar');
262
});
263
264
- it('will call all the normal life cycle methods', function() {
264
+ it('will call all the normal life cycle methods', () => {
265
var lifeCycles = [];
266
class Foo extends React.Component {
267
constructor() {
@@ -314,7 +314,7 @@ describe('ReactES6Class', function() {
314
]);
315
});
316
317
- it('warns when classic properties are defined on the instance, but does not invoke them.', function() {
317
+ it('warns when classic properties are defined on the instance, but does not invoke them.', () => {
318
spyOn(console, 'error');
319
var getDefaultPropsWasCalled = false;
320
var getInitialStateWasCalled = false;
@@ -354,7 +354,7 @@ describe('ReactES6Class', function() {
354
);
355
});
356
357
- it('should warn when misspelling shouldComponentUpdate', function() {
357
+ it('should warn when misspelling shouldComponentUpdate', () => {
358
spyOn(console, 'error');
359
360
class NamedComponent extends React.Component {
@@ -376,7 +376,7 @@ describe('ReactES6Class', function() {
376
);
377
});
378
379
- it('should warn when misspelling componentWillReceiveProps', function() {
379
+ it('should warn when misspelling componentWillReceiveProps', () => {
380
spyOn(console, 'error');
381
382
class NamedComponent extends React.Component {
@@ -397,7 +397,7 @@ describe('ReactES6Class', function() {
397
);
398
});
399
400
- it('should throw AND warn when trying to access classic APIs', function() {
400
+ it('should throw AND warn when trying to access classic APIs', () => {
401
spyOn(console, 'error');
402
var instance = test(<Inner name="foo" />, 'DIV', 'foo');
403
expect(() => instance.replaceState({})).toThrow();
@@ -411,7 +411,7 @@ describe('ReactES6Class', function() {
411
);
412
});
413
414
- it('supports this.context passed via getChildContext', function() {
414
+ it('supports this.context passed via getChildContext', () => {
415
class Bar extends React.Component {
416
render() {
417
return <div className={this.context.bar} />;
@@ -430,7 +430,7 @@ describe('ReactES6Class', function() {
430
test(<Foo />, 'DIV', 'bar-through-context');
431
});
432
433
- it('supports classic refs', function() {
433
+ it('supports classic refs', () => {
434
class Foo extends React.Component {
435
render() {
436
return <Inner name="foo" ref="inner" />;
@@ -440,7 +440,7 @@ describe('ReactES6Class', function() {
440
expect(instance.refs.inner.getName()).toBe('foo');
441
});
442
443
- it('supports drilling through to the DOM using findDOMNode', function() {
443
+ it('supports drilling through to the DOM using findDOMNode', () => {
444
var instance = test(<Inner name="foo" />, 'DIV', 'foo');
445
var node = ReactDOM.findDOMNode(instance);
446
expect(node).toBe(container.firstChild);
src/isomorphic/modern/class/__tests__/ReactPureComponent-test.js
+5
-5
@@ -14,13 +14,13 @@
14
var React;
15
var ReactDOM;
16
17
-describe('ReactPureComponent', function() {
18
- beforeEach(function() {
17
+describe('ReactPureComponent', () => {
18
+ beforeEach(() => {
19
React = require('React');
20
ReactDOM = require('ReactDOM');
21
});
22
23
- it('should render', function() {
23
+ it('should render', () => {
24
var renders = 0;
25
class Component extends React.PureComponent {
26
constructor() {
@@ -63,7 +63,7 @@ describe('ReactPureComponent', function() {
63
expect(renders).toBe(3);
64
});
65
66
- it('can override shouldComponentUpdate', function() {
66
+ it('can override shouldComponentUpdate', () => {
67
var renders = 0;
68
class Component extends React.PureComponent {
69
render() {
@@ -80,7 +80,7 @@ describe('ReactPureComponent', function() {
80
expect(renders).toBe(2);
81
});
82
83
- it('extends React.Component', function() {
83
+ it('extends React.Component', () => {
84
var renders = 0;
85
class Component extends React.PureComponent {
86
render() {
src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
+19
-19
@@ -15,10 +15,10 @@ var React;
15
var ReactDOM;
16
var ReactTestUtils;
17
18
-describe('ReactJSXElement', function() {
18
+describe('ReactJSXElement', () => {
19
var Component;
20
21
- beforeEach(function() {
21
+ beforeEach(() => {
22
jest.resetModuleRegistry();
23
24
React = require('React');
@@ -31,7 +31,7 @@ describe('ReactJSXElement', function() {
31
};
32
});
33
34
- it('returns a complete element according to spec', function() {
34
+ it('returns a complete element according to spec', () => {
35
var element = <Component />;
36
expect(element.type).toBe(Component);
37
expect(element.key).toBe(null);
@@ -41,7 +41,7 @@ describe('ReactJSXElement', function() {
41
expect(element.props).toEqual(expectation);
42
});
43
44
- it('allows a lower-case to be passed as the string type', function() {
44
+ it('allows a lower-case to be passed as the string type', () => {
45
var element = <div />;
46
expect(element.type).toBe('div');
47
expect(element.key).toBe(null);
@@ -51,7 +51,7 @@ describe('ReactJSXElement', function() {
51
expect(element.props).toEqual(expectation);
52
});
53
54
- it('allows a string to be passed as the type', function() {
54
+ it('allows a string to be passed as the type', () => {
55
var TagName = 'div';
56
var element = <TagName />;
57
expect(element.type).toBe('div');
@@ -62,12 +62,12 @@ describe('ReactJSXElement', function() {
62
expect(element.props).toEqual(expectation);
63
});
64
65
- it('returns an immutable element', function() {
65
+ it('returns an immutable element', () => {
66
var element = <Component />;
67
expect(() => element.type = 'div').toThrow();
68
});
69
70
- it('does not reuse the object that is spread into props', function() {
70
+ it('does not reuse the object that is spread into props', () => {
71
var config = {foo: 1};
72
var element = <Component {...config} />;
73
expect(element.props.foo).toBe(1);
@@ -75,7 +75,7 @@ describe('ReactJSXElement', function() {
75
expect(element.props.foo).toBe(1);
76
});
77
78
- it('extracts key and ref from the rest of the props', function() {
78
+ it('extracts key and ref from the rest of the props', () => {
79
var element = <Component key="12" ref="34" foo="56" />;
80
expect(element.type).toBe(Component);
81
expect(element.key).toBe('12');
@@ -85,7 +85,7 @@ describe('ReactJSXElement', function() {
85
expect(element.props).toEqual(expectation);
86
});
87
88
- it('coerces the key to a string', function() {
88
+ it('coerces the key to a string', () => {
89
var element = <Component key={12} foo="56" />;
90
expect(element.type).toBe(Component);
91
expect(element.key).toBe('12');
@@ -95,7 +95,7 @@ describe('ReactJSXElement', function() {
95
expect(element.props).toEqual(expectation);
96
});
97
98
- it('merges JSX children onto the children prop', function() {
98
+ it('merges JSX children onto the children prop', () => {
99
spyOn(console, 'error');
100
var a = 1;
101
var element = <Component children="text">{a}</Component>;
@@ -103,21 +103,21 @@ describe('ReactJSXElement', function() {
103
expect(console.error.calls.count()).toBe(0);
104
});
105
106
- it('does not override children if no JSX children are provided', function() {
106
+ it('does not override children if no JSX children are provided', () => {
107
spyOn(console, 'error');
108
var element = <Component children="text" />;
109
expect(element.props.children).toBe('text');
110
expect(console.error.calls.count()).toBe(0);
111
});
112
113
- it('overrides children if null is provided as a JSX child', function() {
113
+ it('overrides children if null is provided as a JSX child', () => {
114
spyOn(console, 'error');
115
var element = <Component children="text">{null}</Component>;
116
expect(element.props.children).toBe(null);
117
expect(console.error.calls.count()).toBe(0);
118
});
119
120
- it('overrides children if undefined is provided as an argument', function() {
120
+ it('overrides children if undefined is provided as an argument', () => {
121
var element = <Component children="text">{undefined}</Component>;
122
expect(element.props.children).toBe(undefined);
123
@@ -129,7 +129,7 @@ describe('ReactJSXElement', function() {
129
expect(element2.props.children).toBe(undefined);
130
});
131
132
- it('merges JSX children onto the children prop in an array', function() {
132
+ it('merges JSX children onto the children prop in an array', () => {
133
spyOn(console, 'error');
134
var a = 1;
135
var b = 2;
@@ -139,7 +139,7 @@ describe('ReactJSXElement', function() {
139
expect(console.error.calls.count()).toBe(0);
140
});
141
142
- it('allows static methods to be called using the type property', function() {
142
+ it('allows static methods to be called using the type property', () => {
143
spyOn(console, 'error');
144
145
class StaticMethodComponent {
@@ -156,7 +156,7 @@ describe('ReactJSXElement', function() {
156
expect(console.error.calls.count()).toBe(0);
157
});
158
159
- it('identifies valid elements', function() {
159
+ it('identifies valid elements', () => {
160
expect(React.isValidElement(<div />)).toEqual(true);
161
expect(React.isValidElement(<Component />)).toEqual(true);
162
@@ -168,13 +168,13 @@ describe('ReactJSXElement', function() {
168
expect(React.isValidElement({ type: 'div', props: {} })).toEqual(false);
169
});
170
171
- it('is indistinguishable from a plain object', function() {
171
+ it('is indistinguishable from a plain object', () => {
172
var element = <div className="foo" />;
173
var object = {};
174
expect(element.constructor).toBe(object.constructor);
175
});
176
177
- it('should use default prop value when removing a prop', function() {
177
+ it('should use default prop value when removing a prop', () => {
178
Component.defaultProps = {fruit: 'persimmon'};
179
180
var container = document.createElement('div');
@@ -188,7 +188,7 @@ describe('ReactJSXElement', function() {
188
expect(instance.props.fruit).toBe('persimmon');
189
});
190
191
- it('should normalize props with default values', function() {
191
+ it('should normalize props with default values', () => {
192
class NormalizingComponent extends React.Component {
193
render() {
194
return <span>{this.props.prop}</span>;
src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
+16
-16
@@ -17,11 +17,11 @@
17
var React;
18
var ReactTestUtils;
19
20
-describe('ReactJSXElementValidator', function() {
20
+describe('ReactJSXElementValidator', () => {
21
var Component;
22
var RequiredPropComponent;
23
24
- beforeEach(function() {
24
+ beforeEach(() => {
25
jest.resetModuleRegistry();
26
27
React = require('React');
@@ -42,7 +42,7 @@ describe('ReactJSXElementValidator', function() {
42
RequiredPropComponent.propTypes = {prop: React.PropTypes.string.isRequired};
43
});
44
45
- it('warns for keys for arrays of elements in children position', function() {
45
+ it('warns for keys for arrays of elements in children position', () => {
46
spyOn(console, 'error');
47
48
void <Component>{[<Component />, <Component />]}</Component>;
@@ -53,7 +53,7 @@ describe('ReactJSXElementValidator', function() {
53
);
54
});
55
56
- it('warns for keys for arrays of elements with owner info', function() {
56
+ it('warns for keys for arrays of elements with owner info', () => {
57
spyOn(console, 'error');
58
59
class InnerComponent extends React.Component {
@@ -82,7 +82,7 @@ describe('ReactJSXElementValidator', function() {
82
);
83
});
84
85
- it('warns for keys for iterables of elements in rest args', function() {
85
+ it('warns for keys for iterables of elements in rest args', () => {
86
spyOn(console, 'error');
87
88
var iterable = {
@@ -105,7 +105,7 @@ describe('ReactJSXElementValidator', function() {
105
);
106
});
107
108
- it('does not warns for arrays of elements with keys', function() {
108
+ it('does not warns for arrays of elements with keys', () => {
109
spyOn(console, 'error');
110
111
void <Component>{[<Component key="#1" />, <Component key="#2" />]}</Component>;
@@ -113,7 +113,7 @@ describe('ReactJSXElementValidator', function() {
113
expect(console.error.calls.count()).toBe(0);
114
});
115
116
- it('does not warns for iterable elements with keys', function() {
116
+ it('does not warns for iterable elements with keys', () => {
117
spyOn(console, 'error');
118
119
var iterable = {
@@ -136,7 +136,7 @@ describe('ReactJSXElementValidator', function() {
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() {
139
+ it('does not warn for numeric keys in entry iterable as a child', () => {
140
spyOn(console, 'error');
141
142
var iterable = {
@@ -157,7 +157,7 @@ describe('ReactJSXElementValidator', function() {
157
expect(console.error.calls.count()).toBe(0);
158
});
159
160
- it('does not warn when the element is directly as children', function() {
160
+ it('does not warn when the element is directly as children', () => {
161
spyOn(console, 'error');
162
163
void <Component><Component /><Component /></Component>;
@@ -165,7 +165,7 @@ describe('ReactJSXElementValidator', function() {
165
expect(console.error.calls.count()).toBe(0);
166
});
167
168
- it('does not warn when the child array contains non-elements', function() {
168
+ it('does not warn when the child array contains non-elements', () => {
169
spyOn(console, 'error');
170
171
void <Component>{[{}, {}]}</Component>;
@@ -238,7 +238,7 @@ describe('ReactJSXElementValidator', function() {
238
expect(console.error.calls.count()).toBe(4);
239
});
240
241
- it('should check default prop values', function() {
241
+ it('should check default prop values', () => {
242
spyOn(console, 'error');
243
244
RequiredPropComponent.defaultProps = {prop: null};
@@ -255,7 +255,7 @@ describe('ReactJSXElementValidator', function() {
255
);
256
});
257
258
- it('should not check the default for explicit null', function() {
258
+ it('should not check the default for explicit null', () => {
259
spyOn(console, 'error');
260
261
ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop={null} />);
@@ -270,7 +270,7 @@ describe('ReactJSXElementValidator', function() {
270
);
271
});
272
273
- it('should check declared prop types', function() {
273
+ it('should check declared prop types', () => {
274
spyOn(console, 'error');
275
276
ReactTestUtils.renderIntoDocument(<RequiredPropComponent />);
@@ -301,7 +301,7 @@ describe('ReactJSXElementValidator', function() {
301
expect(console.error.calls.count()).toBe(2);
302
});
303
304
- it('should warn on invalid prop types', function() {
304
+ it('should warn on invalid prop types', () => {
305
// Since there is no prevalidation step for ES6 classes, there is no hook
306
// for us to issue a warning earlier than element creation when the error
307
// actually occurs. Since this step is skipped in production, we should just
@@ -323,7 +323,7 @@ describe('ReactJSXElementValidator', function() {
323
);
324
});
325
326
- it('should warn on invalid context types', function() {
326
+ it('should warn on invalid context types', () => {
327
spyOn(console, 'error');
328
class NullContextTypeComponent extends React.Component {
329
render() {
@@ -341,7 +341,7 @@ describe('ReactJSXElementValidator', function() {
341
);
342
});
343
344
- it('should warn if getDefaultProps is specificed on the class', function() {
344
+ it('should warn if getDefaultProps is specificed on the class', () => {
345
spyOn(console, 'error');
346
class GetDefaultPropsComponent extends React.Component {
347
render() {
src/renderers/art/__tests__/ReactART-test.js
+9
-9
@@ -48,9 +48,9 @@ function testDOMNodeStructure(domNode, expectedStructure) {
48
}
49
}
50
51
-describe('ReactART', function() {
51
+describe('ReactART', () => {
52
53
- beforeEach(function() {
53
+ beforeEach(() => {
54
ARTCurrentMode.setCurrent(ARTSVGMode);
55
56
Group = ReactART.Group;
@@ -96,7 +96,7 @@ describe('ReactART', function() {
96
};
97
});
98
99
- it('should have the correct lifecycle state', function() {
99
+ it('should have the correct lifecycle state', () => {
100
var instance = <TestComponent />;
101
instance = ReactTestUtils.renderIntoDocument(instance);
102
var group = instance.refs.group;
@@ -104,7 +104,7 @@ describe('ReactART', function() {
104
expect(typeof group.indicate).toBe('function');
105
});
106
107
- it('should render a reasonable SVG structure in SVG mode', function() {
107
+ it('should render a reasonable SVG structure in SVG mode', () => {
108
var instance = <TestComponent />;
109
instance = ReactTestUtils.renderIntoDocument(instance);
110
@@ -135,7 +135,7 @@ describe('ReactART', function() {
135
testDOMNodeStructure(realNode, expectedStructure);
136
});
137
138
- it('should be able to reorder components', function() {
138
+ it('should be able to reorder components', () => {
139
var container = document.createElement('div');
140
var instance = ReactDOM.render(<TestComponent flipped={false} />, container);
141
@@ -179,7 +179,7 @@ describe('ReactART', function() {
179
testDOMNodeStructure(realNode, expectedNewStructure);
180
});
181
182
- it('should be able to reorder many components', function() {
182
+ it('should be able to reorder many components', () => {
183
var container = document.createElement('div');
184
185
class Component extends React.Component {
@@ -207,7 +207,7 @@ describe('ReactART', function() {
207
ReactDOM.unmountComponentAtNode(container);
208
});
209
210
- it('renders composite with lifecycle inside group', function() {
210
+ it('renders composite with lifecycle inside group', () => {
211
var mounted = false;
212
213
class CustomShape extends React.Component {
@@ -230,7 +230,7 @@ describe('ReactART', function() {
230
expect(mounted).toBe(true);
231
});
232
233
- it('resolves refs before componentDidMount', function() {
233
+ it('resolves refs before componentDidMount', () => {
234
class CustomShape extends React.Component {
235
render() {
236
return <Shape />;
@@ -259,7 +259,7 @@ describe('ReactART', function() {
259
expect(ref.constructor).toBe(CustomShape);
260
});
261
262
- it('resolves refs before componentDidUpdate', function() {
262
+ it('resolves refs before componentDidUpdate', () => {
263
class CustomShape extends React.Component {
264
render() {
265
return <Shape />;
src/renderers/dom/__tests__/ReactDOMProduction-test.js
+8
-8
@@ -10,13 +10,13 @@
10
*/
11
'use strict';
12
13
-describe('ReactDOMProduction', function() {
13
+describe('ReactDOMProduction', () => {
14
var oldProcess;
15
16
var React;
17
var ReactDOM;
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
__DEV__ = false;
21
oldProcess = process;
22
global.process = {env: {NODE_ENV: 'production'}};
@@ -26,12 +26,12 @@ describe('ReactDOMProduction', function() {
26
ReactDOM = require('ReactDOM');
27
});
28
29
- afterEach(function() {
29
+ afterEach(() => {
30
__DEV__ = true;
31
global.process = oldProcess;
32
});
33
34
- it('should use prod fbjs', function() {
34
+ it('should use prod fbjs', () => {
35
var warning = require('warning');
36
37
spyOn(console, 'error');
@@ -39,7 +39,7 @@ describe('ReactDOMProduction', function() {
39
expect(console.error.calls.count()).toBe(0);
40
});
41
42
- it('should use prod React', function() {
42
+ it('should use prod React', () => {
43
spyOn(console, 'error');
44
45
// no key warning
@@ -48,7 +48,7 @@ describe('ReactDOMProduction', function() {
48
expect(console.error.calls.count()).toBe(0);
49
});
50
51
- it('should handle a simple flow', function() {
51
+ it('should handle a simple flow', () => {
52
class Component extends React.Component {
53
render() {
54
return <span>{this.props.children}</span>;
@@ -86,7 +86,7 @@ describe('ReactDOMProduction', function() {
86
expect(container.childNodes.length).toBe(0);
87
});
88
89
- it('should call lifecycle methods', function() {
89
+ it('should call lifecycle methods', () => {
90
var log = [];
91
class Component extends React.Component {
92
state = {y: 1};
@@ -174,7 +174,7 @@ describe('ReactDOMProduction', function() {
174
]);
175
});
176
177
- it('should throw with an error code in production', function() {
177
+ it('should throw with an error code in production', () => {
178
expect(function() {
179
class Component extends React.Component {
180
render() {
src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js
+24
-24
@@ -55,8 +55,8 @@ function getInternal(node) {
55
}
56
57
58
-describe('ReactBrowserEventEmitter', function() {
59
- beforeEach(function() {
58
+describe('ReactBrowserEventEmitter', () => {
59
+ beforeEach(() => {
60
jest.resetModuleRegistry();
61
LISTENER.mockClear();
62
EventListener = require('EventListener');
@@ -83,26 +83,26 @@ describe('ReactBrowserEventEmitter', function() {
83
});
84
});
85
86
- it('should store a listener correctly', function() {
86
+ it('should store a listener correctly', () => {
87
registerSimpleTestHandler();
88
var listener = EventPluginHub.getListener(getInternal(CHILD), ON_CLICK_KEY);
89
expect(listener).toBe(LISTENER);
90
});
91
92
- it('should retrieve a listener correctly', function() {
92
+ it('should retrieve a listener correctly', () => {
93
registerSimpleTestHandler();
94
var listener = EventPluginHub.getListener(getInternal(CHILD), ON_CLICK_KEY);
95
expect(listener).toEqual(LISTENER);
96
});
97
98
- it('should clear all handlers when asked to', function() {
98
+ it('should clear all handlers when asked to', () => {
99
registerSimpleTestHandler();
100
EventPluginHub.deleteAllListeners(getInternal(CHILD));
101
var listener = EventPluginHub.getListener(getInternal(CHILD), ON_CLICK_KEY);
102
expect(listener).toBe(undefined);
103
});
104
105
- it('should invoke a simple handler registered on a node', function() {
105
+ it('should invoke a simple handler registered on a node', () => {
106
registerSimpleTestHandler();
107
ReactTestUtils.Simulate.click(CHILD);
108
expect(LISTENER.mock.calls.length).toBe(1);
@@ -110,7 +110,7 @@ describe('ReactBrowserEventEmitter', function() {
110
111
it(
112
'should not invoke handlers if ReactBrowserEventEmitter is disabled',
113
- function() {
113
+ () => {
114
registerSimpleTestHandler();
115
ReactBrowserEventEmitter.setEnabled(false);
116
ReactTestUtils.SimulateNative.click(CHILD);
@@ -121,7 +121,7 @@ describe('ReactBrowserEventEmitter', function() {
121
}
122
);
123
124
- it('should bubble simply', function() {
124
+ it('should bubble simply', () => {
125
EventPluginHub.putListener(
126
getInternal(CHILD),
127
ON_CLICK_KEY,
@@ -144,7 +144,7 @@ describe('ReactBrowserEventEmitter', function() {
144
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
145
});
146
147
- it('should continue bubbling if an error is thrown', function() {
147
+ it('should continue bubbling if an error is thrown', () => {
148
EventPluginHub.putListener(
149
getInternal(CHILD),
150
ON_CLICK_KEY,
@@ -172,7 +172,7 @@ describe('ReactBrowserEventEmitter', function() {
172
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
173
});
174
175
- it('should set currentTarget', function() {
175
+ it('should set currentTarget', () => {
176
EventPluginHub.putListener(
177
getInternal(CHILD),
178
ON_CLICK_KEY,
@@ -204,7 +204,7 @@ describe('ReactBrowserEventEmitter', function() {
204
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
205
});
206
207
- it('should support stopPropagation()', function() {
207
+ it('should support stopPropagation()', () => {
208
EventPluginHub.putListener(
209
getInternal(CHILD),
210
ON_CLICK_KEY,
@@ -226,7 +226,7 @@ describe('ReactBrowserEventEmitter', function() {
226
expect(idCallOrder[1]).toBe(getInternal(PARENT));
227
});
228
229
- it('should stop after first dispatch if stopPropagation', function() {
229
+ it('should stop after first dispatch if stopPropagation', () => {
230
EventPluginHub.putListener(
231
getInternal(CHILD),
232
ON_CLICK_KEY,
@@ -247,7 +247,7 @@ describe('ReactBrowserEventEmitter', function() {
247
expect(idCallOrder[0]).toBe(getInternal(CHILD));
248
});
249
250
- it('should not stopPropagation if false is returned', function() {
250
+ it('should not stopPropagation if false is returned', () => {
251
EventPluginHub.putListener(
252
getInternal(CHILD),
253
ON_CLICK_KEY,
@@ -281,7 +281,7 @@ describe('ReactBrowserEventEmitter', function() {
281
* these new listeners.
282
*/
283
284
- it('should invoke handlers that were removed while bubbling', function() {
284
+ it('should invoke handlers that were removed while bubbling', () => {
285
var handleParentClick = jest.fn();
286
var handleChildClick = function(event) {
287
EventPluginHub.deleteAllListeners(getInternal(PARENT));
@@ -300,7 +300,7 @@ describe('ReactBrowserEventEmitter', function() {
300
expect(handleParentClick.mock.calls.length).toBe(1);
301
});
302
303
- it('should not invoke newly inserted handlers while bubbling', function() {
303
+ it('should not invoke newly inserted handlers while bubbling', () => {
304
var handleParentClick = jest.fn();
305
var handleChildClick = function(event) {
306
EventPluginHub.putListener(
@@ -318,7 +318,7 @@ describe('ReactBrowserEventEmitter', function() {
318
expect(handleParentClick.mock.calls.length).toBe(0);
319
});
320
321
- it('should have mouse enter simulated by test utils', function() {
321
+ it('should have mouse enter simulated by test utils', () => {
322
EventPluginHub.putListener(
323
getInternal(CHILD),
324
ON_MOUSE_ENTER_KEY,
@@ -329,7 +329,7 @@ describe('ReactBrowserEventEmitter', function() {
329
expect(idCallOrder[0]).toBe(getInternal(CHILD));
330
});
331
332
- it('should infer onTouchTap from a touchStart/End', function() {
332
+ it('should infer onTouchTap from a touchStart/End', () => {
333
EventPluginHub.putListener(
334
getInternal(CHILD),
335
ON_TOUCH_TAP_KEY,
@@ -347,7 +347,7 @@ describe('ReactBrowserEventEmitter', function() {
347
expect(idCallOrder[0]).toBe(getInternal(CHILD));
348
});
349
350
- it('should infer onTouchTap from when dragging below threshold', function() {
350
+ it('should infer onTouchTap from when dragging below threshold', () => {
351
EventPluginHub.putListener(
352
getInternal(CHILD),
353
ON_TOUCH_TAP_KEY,
@@ -365,7 +365,7 @@ describe('ReactBrowserEventEmitter', function() {
365
expect(idCallOrder[0]).toBe(getInternal(CHILD));
366
});
367
368
- it('should not onTouchTap from when dragging beyond threshold', function() {
368
+ it('should not onTouchTap from when dragging beyond threshold', () => {
369
EventPluginHub.putListener(
370
getInternal(CHILD),
371
ON_TOUCH_TAP_KEY,
@@ -382,14 +382,14 @@ describe('ReactBrowserEventEmitter', function() {
382
expect(idCallOrder.length).toBe(0);
383
});
384
385
- it('should listen to events only once', function() {
385
+ it('should listen to events only once', () => {
386
spyOn(EventListener, 'listen');
387
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
388
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
389
expect(EventListener.listen.calls.count()).toBe(1);
390
});
391
392
- it('should work with event plugins without dependencies', function() {
392
+ it('should work with event plugins without dependencies', () => {
393
spyOn(EventListener, 'listen');
394
395
ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
@@ -397,7 +397,7 @@ describe('ReactBrowserEventEmitter', function() {
397
expect(EventListener.listen.calls.argsFor(0)[1]).toBe('click');
398
});
399
400
- it('should work with event plugins with dependencies', function() {
400
+ it('should work with event plugins with dependencies', () => {
401
spyOn(EventListener, 'listen');
402
spyOn(EventListener, 'capture');
403
@@ -422,7 +422,7 @@ describe('ReactBrowserEventEmitter', function() {
422
}
423
});
424
425
- it('should bubble onTouchTap', function() {
425
+ it('should bubble onTouchTap', () => {
426
EventPluginHub.putListener(
427
getInternal(CHILD),
428
ON_TOUCH_TAP_KEY,
@@ -452,7 +452,7 @@ describe('ReactBrowserEventEmitter', function() {
452
expect(idCallOrder[2]).toBe(getInternal(GRANDPARENT));
453
});
454
455
- it('should not crash ensureScrollValueMonitoring when createEvent returns null', function() {
455
+ it('should not crash ensureScrollValueMonitoring when createEvent returns null', () => {
456
var originalCreateEvent = document.createEvent;
457
document.createEvent = function() {
458
return null;
src/renderers/dom/client/__tests__/ReactDOM-test.js
+8
-8
@@ -16,7 +16,7 @@ var ReactDOM = require('ReactDOM');
16
var ReactTestUtils = require('ReactTestUtils');
17
var div = React.createFactory('div');
18
19
-describe('ReactDOM', function() {
19
+describe('ReactDOM', () => {
20
// TODO: uncomment this test once we can run in phantom, which
21
// supports real submit events.
22
/*
@@ -46,13 +46,13 @@ describe('ReactDOM', function() {
46
});
47
*/
48
49
- it('allows a DOM element to be used with a string', function() {
49
+ it('allows a DOM element to be used with a string', () => {
50
var element = React.createElement('div', {className: 'foo'});
51
var instance = ReactTestUtils.renderIntoDocument(element);
52
expect(ReactDOM.findDOMNode(instance).tagName).toBe('DIV');
53
});
54
55
- it('should allow children to be passed as an argument', function() {
55
+ it('should allow children to be passed as an argument', () => {
56
var argDiv = ReactTestUtils.renderIntoDocument(
57
div(null, 'child')
58
);
@@ -60,7 +60,7 @@ describe('ReactDOM', function() {
60
expect(argNode.innerHTML).toBe('child');
61
});
62
63
- it('should overwrite props.children with children argument', function() {
63
+ it('should overwrite props.children with children argument', () => {
64
var conflictDiv = ReactTestUtils.renderIntoDocument(
65
div({children: 'fakechild'}, 'child')
66
);
@@ -72,7 +72,7 @@ describe('ReactDOM', function() {
72
* We need to make sure that updates occur to the actual node that's in the
73
* DOM, instead of a stale cache.
74
*/
75
- it('should purge the DOM cache when removing nodes', function() {
75
+ it('should purge the DOM cache when removing nodes', () => {
76
var myDiv = ReactTestUtils.renderIntoDocument(
77
<div>
78
<div key="theDog" className="dog" />,
@@ -111,14 +111,14 @@ describe('ReactDOM', function() {
111
expect(dog.className).toBe('bigdog');
112
});
113
114
- it('allow React.DOM factories to be called without warnings', function() {
114
+ it('allow React.DOM factories to be called without warnings', () => {
115
spyOn(console, 'error');
116
var element = React.DOM.div();
117
expect(element.type).toBe('div');
118
expect(console.error.calls.count()).toBe(0);
119
});
120
121
- it('throws in render() if the mount callback is not a function', function() {
121
+ it('throws in render() if the mount callback is not a function', () => {
122
function Foo() {
123
this.a = 1;
124
this.b = 2;
@@ -147,7 +147,7 @@ describe('ReactDOM', function() {
147
);
148
});
149
150
- it('throws in render() if the update callback is not a function', function() {
150
+ it('throws in render() if the update callback is not a function', () => {
151
function Foo() {
152
this.a = 1;
153
this.b = 2;
src/renderers/dom/client/__tests__/ReactDOMComponentTree-test.js
+4
-4
@@ -11,7 +11,7 @@
11
12
'use strict';
13
14
-describe('ReactDOMComponentTree', function() {
14
+describe('ReactDOMComponentTree', () => {
15
var React;
16
var ReactDOM;
17
var ReactDOMComponentTree;
@@ -24,14 +24,14 @@ describe('ReactDOMComponentTree', function() {
24
return ReactDOM.render(elt, container);
25
}
26
27
- beforeEach(function() {
27
+ beforeEach(() => {
28
React = require('React');
29
ReactDOM = require('ReactDOM');
30
ReactDOMComponentTree = require('ReactDOMComponentTree');
31
ReactDOMServer = require('ReactDOMServer');
32
});
33
34
- it('finds nodes for instances', function() {
34
+ it('finds nodes for instances', () => {
35
// This is a little hard to test directly. But refs rely on it -- so we
36
// check that we can find a ref at arbitrary points in the tree, even if
37
// other nodes don't have a ref.
@@ -61,7 +61,7 @@ describe('ReactDOMComponentTree', function() {
61
expect(renderAndGetRef('input')).toBe('INPUT');
62
});
63
64
- it('finds instances for nodes', function() {
64
+ it('finds instances for nodes', () => {
65
class Component extends React.Component {
66
render() {
67
return (
src/renderers/dom/client/__tests__/ReactDOMIDOperations-test.js
+2
-2
@@ -11,11 +11,11 @@
11
12
'use strict';
13
14
-describe('ReactDOMIDOperations', function() {
14
+describe('ReactDOMIDOperations', () => {
15
var ReactDOMComponentTree = require('ReactDOMComponentTree');
16
var ReactDOMIDOperations = require('ReactDOMIDOperations');
17
18
- it('should update innerHTML and preserve whitespace', function() {
18
+ it('should update innerHTML and preserve whitespace', () => {
19
var stubNode = document.createElement('div');
20
var stubInstance = {_debugID: 1};
21
ReactDOMComponentTree.precacheNode(stubInstance, stubNode);
src/renderers/dom/client/__tests__/ReactDOMSVG-test.js
+3
-3
@@ -14,14 +14,14 @@
14
var React;
15
var ReactDOMServer;
16
17
-describe('ReactDOMSVG', function() {
17
+describe('ReactDOMSVG', () => {
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
React = require('React');
21
ReactDOMServer = require('ReactDOMServer');
22
});
23
24
- it('creates initial namespaced markup', function() {
24
+ it('creates initial namespaced markup', () => {
25
var markup = ReactDOMServer.renderToString(
26
<svg>
27
<image xlinkHref="http://i.imgur.com/w7GCRPb.png" />
src/renderers/dom/client/__tests__/ReactDOMTreeTraversal-test.js
+17
-17
@@ -50,7 +50,7 @@ function renderParentIntoDocument() {
50
return ReactTestUtils.renderIntoDocument(<ParentComponent />);
51
}
52
53
-describe('ReactDOMTreeTraversal', function() {
53
+describe('ReactDOMTreeTraversal', () => {
54
var ReactDOMTreeTraversal;
55
56
var aggregatedArgs;
@@ -66,19 +66,19 @@ describe('ReactDOMTreeTraversal', function() {
66
return ReactDOMComponentTree.getInstanceFromNode(node);
67
}
68
69
- beforeEach(function() {
69
+ beforeEach(() => {
70
ReactDOMTreeTraversal = require('ReactDOMTreeTraversal');
71
aggregatedArgs = [];
72
});
73
74
- describe('traverseTwoPhase', function() {
75
- it('should not traverse when traversing outside DOM', function() {
74
+ describe('traverseTwoPhase', () => {
75
+ it('should not traverse when traversing outside DOM', () => {
76
var expectedAggregation = [];
77
ReactDOMTreeTraversal.traverseTwoPhase(null, argAggregator, ARG);
78
expect(aggregatedArgs).toEqual(expectedAggregation);
79
});
80
81
- it('should traverse two phase across component boundary', function() {
81
+ it('should traverse two phase across component boundary', () => {
82
var parent = renderParentIntoDocument();
83
var target = getInst(parent.refs.P_P1_C1.refs.DIV_1);
84
var expectedAggregation = [
@@ -96,7 +96,7 @@ describe('ReactDOMTreeTraversal', function() {
96
expect(aggregatedArgs).toEqual(expectedAggregation);
97
});
98
99
- it('should traverse two phase at shallowest node', function() {
99
+ it('should traverse two phase at shallowest node', () => {
100
var parent = renderParentIntoDocument();
101
var target = getInst(parent.refs.P);
102
var expectedAggregation = [
@@ -108,8 +108,8 @@ describe('ReactDOMTreeTraversal', function() {
108
});
109
});
110
111
- describe('traverseEnterLeave', function() {
112
- it('should not traverse when enter/leaving outside DOM', function() {
111
+ describe('traverseEnterLeave', () => {
112
+ it('should not traverse when enter/leaving outside DOM', () => {
113
var target = null;
114
var expectedAggregation = [];
115
ReactDOMTreeTraversal.traverseEnterLeave(
@@ -118,7 +118,7 @@ describe('ReactDOMTreeTraversal', function() {
118
expect(aggregatedArgs).toEqual(expectedAggregation);
119
});
120
121
- it('should not traverse if enter/leave the same node', function() {
121
+ it('should not traverse if enter/leave the same node', () => {
122
var parent = renderParentIntoDocument();
123
var leave = getInst(parent.refs.P_P1_C1.refs.DIV_1);
124
var enter = getInst(parent.refs.P_P1_C1.refs.DIV_1);
@@ -129,7 +129,7 @@ describe('ReactDOMTreeTraversal', function() {
129
expect(aggregatedArgs).toEqual(expectedAggregation);
130
});
131
132
- it('should traverse enter/leave to sibling - avoids parent', function() {
132
+ it('should traverse enter/leave to sibling - avoids parent', () => {
133
var parent = renderParentIntoDocument();
134
var leave = getInst(parent.refs.P_P1_C1.refs.DIV_1);
135
var enter = getInst(parent.refs.P_P1_C1.refs.DIV_2);
@@ -144,7 +144,7 @@ describe('ReactDOMTreeTraversal', function() {
144
expect(aggregatedArgs).toEqual(expectedAggregation);
145
});
146
147
- it('should traverse enter/leave to parent - avoids parent', function() {
147
+ it('should traverse enter/leave to parent - avoids parent', () => {
148
var parent = renderParentIntoDocument();
149
var leave = getInst(parent.refs.P_P1_C1.refs.DIV_1);
150
var enter = getInst(parent.refs.P_P1_C1.refs.DIV);
@@ -157,7 +157,7 @@ describe('ReactDOMTreeTraversal', function() {
157
expect(aggregatedArgs).toEqual(expectedAggregation);
158
});
159
160
- it('should enter from the window', function() {
160
+ it('should enter from the window', () => {
161
var parent = renderParentIntoDocument();
162
var leave = null; // From the window or outside of the React sandbox.
163
var enter = getInst(parent.refs.P_P1_C1.refs.DIV);
@@ -172,7 +172,7 @@ describe('ReactDOMTreeTraversal', function() {
172
expect(aggregatedArgs).toEqual(expectedAggregation);
173
});
174
175
- it('should enter from the window to the shallowest', function() {
175
+ it('should enter from the window to the shallowest', () => {
176
var parent = renderParentIntoDocument();
177
var leave = null; // From the window or outside of the React sandbox.
178
var enter = getInst(parent.refs.P);
@@ -185,7 +185,7 @@ describe('ReactDOMTreeTraversal', function() {
185
expect(aggregatedArgs).toEqual(expectedAggregation);
186
});
187
188
- it('should leave to the window', function() {
188
+ it('should leave to the window', () => {
189
var parent = renderParentIntoDocument();
190
var enter = null; // From the window or outside of the React sandbox.
191
var leave = getInst(parent.refs.P_P1_C1.refs.DIV);
@@ -200,7 +200,7 @@ describe('ReactDOMTreeTraversal', function() {
200
expect(aggregatedArgs).toEqual(expectedAggregation);
201
});
202
203
- it('should leave to the window from the shallowest', function() {
203
+ it('should leave to the window from the shallowest', () => {
204
var parent = renderParentIntoDocument();
205
var enter = null; // From the window or outside of the React sandbox.
206
var leave = getInst(parent.refs.P_P1_C1.refs.DIV);
@@ -216,8 +216,8 @@ describe('ReactDOMTreeTraversal', function() {
216
});
217
});
218
219
- describe('getFirstCommonAncestor', function() {
220
- it('should determine the first common ancestor correctly', function() {
219
+ describe('getFirstCommonAncestor', () => {
220
+ it('should determine the first common ancestor correctly', () => {
221
var parent = renderParentIntoDocument();
222
var ancestors = [
223
// Common ancestor with self is self.
src/renderers/dom/client/__tests__/ReactEventIndependence-test.js
+5
-5
@@ -15,8 +15,8 @@ var React;
15
var ReactDOM;
16
var ReactTestUtils;
17
18
-describe('ReactEventIndependence', function() {
19
- beforeEach(function() {
18
+describe('ReactEventIndependence', () => {
19
+ beforeEach(() => {
20
jest.resetModuleRegistry();
21
22
React = require('React');
@@ -24,7 +24,7 @@ describe('ReactEventIndependence', function() {
24
ReactTestUtils = require('ReactTestUtils');
25
});
26
27
- it('does not crash with other react inside', function() {
27
+ it('does not crash with other react inside', () => {
28
var clicks = 0;
29
var div = ReactTestUtils.renderIntoDocument(
30
<div
@@ -38,7 +38,7 @@ describe('ReactEventIndependence', function() {
38
expect(clicks).toBe(1);
39
});
40
41
- it('does not crash with other react outside', function() {
41
+ it('does not crash with other react outside', () => {
42
var clicks = 0;
43
var outer = document.createElement('div');
44
outer.setAttribute('data-reactid', '.z');
@@ -50,7 +50,7 @@ describe('ReactEventIndependence', function() {
50
expect(clicks).toBe(1);
51
});
52
53
- it('does not when event fired on unmounted tree', function() {
53
+ it('does not when event fired on unmounted tree', () => {
54
var clicks = 0;
55
var container = document.createElement('div');
56
var button = ReactDOM.render(
src/renderers/dom/client/__tests__/ReactEventListener-test.js
+9
-9
@@ -14,7 +14,7 @@
14
15
var EVENT_TARGET_PARAM = 1;
16
17
-describe('ReactEventListener', function() {
17
+describe('ReactEventListener', () => {
18
var React;
19
var ReactDOM;
20
var ReactDOMComponentTree;
@@ -22,7 +22,7 @@ describe('ReactEventListener', function() {
22
var ReactTestUtils;
23
var handleTopLevel;
24
25
- beforeEach(function() {
25
+ beforeEach(() => {
26
jest.resetModuleRegistry();
27
React = require('React');
28
ReactDOM = require('ReactDOM');
@@ -34,7 +34,7 @@ describe('ReactEventListener', function() {
34
ReactEventListener._handleTopLevel = handleTopLevel;
35
});
36
37
- it('should dispatch events from outside React tree', function() {
37
+ it('should dispatch events from outside React tree', () => {
38
var otherNode = document.createElement('h1');
39
var component = ReactDOM.render(<div />, document.createElement('div'));
40
expect(handleTopLevel.mock.calls.length).toBe(0);
@@ -54,8 +54,8 @@ describe('ReactEventListener', function() {
54
expect(handleTopLevel.mock.calls.length).toBe(1);
55
});
56
57
- describe('Propagation', function() {
58
- it('should propagate events one level down', function() {
57
+ describe('Propagation', () => {
58
+ it('should propagate events one level down', () => {
59
var childContainer = document.createElement('div');
60
var childControl = <div>Child</div>;
61
var parentContainer = document.createElement('div');
@@ -78,7 +78,7 @@ describe('ReactEventListener', function() {
78
.toBe(ReactDOMComponentTree.getInstanceFromNode(parentControl));
79
});
80
81
- it('should propagate events two levels down', function() {
81
+ it('should propagate events two levels down', () => {
82
var childContainer = document.createElement('div');
83
var childControl = <div>Child</div>;
84
var parentContainer = document.createElement('div');
@@ -108,7 +108,7 @@ describe('ReactEventListener', function() {
108
.toBe(ReactDOMComponentTree.getInstanceFromNode(grandParentControl));
109
});
110
111
- it('should not get confused by disappearing elements', function() {
111
+ it('should not get confused by disappearing elements', () => {
112
var childContainer = document.createElement('div');
113
var childControl = <div>Child</div>;
114
var parentContainer = document.createElement('div');
@@ -144,7 +144,7 @@ describe('ReactEventListener', function() {
144
.toBe(ReactDOMComponentTree.getInstanceFromNode(parentControl));
145
});
146
147
- it('should batch between handlers from different roots', function() {
147
+ it('should batch between handlers from different roots', () => {
148
var childContainer = document.createElement('div');
149
var parentContainer = document.createElement('div');
150
var childControl = ReactDOM.render(
@@ -183,7 +183,7 @@ describe('ReactEventListener', function() {
183
});
184
});
185
186
- it('should not fire duplicate events for a React DOM tree', function() {
186
+ it('should not fire duplicate events for a React DOM tree', () => {
187
class Wrapper extends React.Component {
188
getInner = () => {
189
return this.refs.inner;
src/renderers/dom/client/__tests__/ReactMount-test.js
+19
-19
@@ -18,8 +18,8 @@ var ReactMount;
18
var ReactTestUtils;
19
var WebComponents;
20
21
-describe('ReactMount', function() {
22
- beforeEach(function() {
21
+describe('ReactMount', () => {
22
+ beforeEach(() => {
23
jest.resetModuleRegistry();
24
25
React = require('React');
@@ -39,8 +39,8 @@ describe('ReactMount', function() {
39
}
40
});
41
42
- describe('unmountComponentAtNode', function() {
43
- it('throws when given a non-node', function() {
42
+ describe('unmountComponentAtNode', () => {
43
+ it('throws when given a non-node', () => {
44
var nodeArray = document.getElementsByTagName('div');
45
expect(function() {
46
ReactDOM.unmountComponentAtNode(nodeArray);
@@ -50,7 +50,7 @@ describe('ReactMount', function() {
50
});
51
});
52
53
- it('throws when given a string', function() {
53
+ it('throws when given a string', () => {
54
expect(function() {
55
ReactTestUtils.renderIntoDocument('div');
56
}).toThrowError(
@@ -59,7 +59,7 @@ describe('ReactMount', function() {
59
);
60
});
61
62
- it('throws when given a factory', function() {
62
+ it('throws when given a factory', () => {
63
class Component extends React.Component {
64
render() {
65
return <div />;
@@ -74,7 +74,7 @@ describe('ReactMount', function() {
74
);
75
});
76
77
- it('should render different components in same root', function() {
77
+ it('should render different components in same root', () => {
78
var container = document.createElement('container');
79
document.body.appendChild(container);
80
@@ -85,7 +85,7 @@ describe('ReactMount', function() {
85
expect(container.firstChild.nodeName).toBe('SPAN');
86
});
87
88
- it('should unmount and remount if the key changes', function() {
88
+ it('should unmount and remount if the key changes', () => {
89
var container = document.createElement('container');
90
91
var mockMount = jest.fn();
@@ -120,7 +120,7 @@ describe('ReactMount', function() {
120
expect(mockUnmount.mock.calls.length).toBe(1);
121
});
122
123
- it('should reuse markup if rendering to the same target twice', function() {
123
+ it('should reuse markup if rendering to the same target twice', () => {
124
var container = document.createElement('container');
125
var instance1 = ReactDOM.render(<div />, container);
126
var instance2 = ReactDOM.render(<div />, container);
@@ -128,7 +128,7 @@ describe('ReactMount', function() {
128
expect(instance1 === instance2).toBe(true);
129
});
130
131
- it('should warn if mounting into dirty rendered markup', function() {
131
+ it('should warn if mounting into dirty rendered markup', () => {
132
var container = document.createElement('container');
133
container.innerHTML = ReactDOMServer.renderToString(<div />) + ' ';
134
@@ -142,7 +142,7 @@ describe('ReactMount', function() {
142
expect(console.error.calls.count()).toBe(2);
143
});
144
145
- it('should not warn if mounting into non-empty node', function() {
145
+ it('should not warn if mounting into non-empty node', () => {
146
var container = document.createElement('container');
147
container.innerHTML = '<div></div>';
148
@@ -151,7 +151,7 @@ describe('ReactMount', function() {
151
expect(console.error.calls.count()).toBe(0);
152
});
153
154
- it('should warn when mounting into document.body', function() {
154
+ it('should warn when mounting into document.body', () => {
155
var iFrame = document.createElement('iframe');
156
document.body.appendChild(iFrame);
157
spyOn(console, 'error');
@@ -164,7 +164,7 @@ describe('ReactMount', function() {
164
);
165
});
166
167
- it('should account for escaping on a checksum mismatch', function() {
167
+ it('should account for escaping on a checksum mismatch', () => {
168
var div = document.createElement('div');
169
var markup = ReactDOMServer.renderToString(
170
<div>This markup contains an nbsp entity: server text</div>);
@@ -183,7 +183,7 @@ describe('ReactMount', function() {
183
});
184
185
if (WebComponents !== undefined) {
186
- it('should allow mounting/unmounting to document fragment container', function() {
186
+ it('should allow mounting/unmounting to document fragment container', () => {
187
var shadowRoot;
188
var proto = Object.create(HTMLElement.prototype, {
189
createdCallback: {
@@ -205,7 +205,7 @@ describe('ReactMount', function() {
205
});
206
}
207
208
- it('should warn if render removes React-rendered children', function() {
208
+ it('should warn if render removes React-rendered children', () => {
209
var container = document.createElement('container');
210
211
class Component extends React.Component {
@@ -229,7 +229,7 @@ describe('ReactMount', function() {
229
);
230
});
231
232
- it('should warn if the unmounted node was rendered by another copy of React', function() {
232
+ it('should warn if the unmounted node was rendered by another copy of React', () => {
233
jest.resetModuleRegistry();
234
var ReactDOMOther = require('ReactDOM');
235
var container = document.createElement('div');
@@ -257,7 +257,7 @@ describe('ReactMount', function() {
257
expect(console.error.calls.count()).toBe(1);
258
});
259
260
- it('passes the correct callback context', function() {
260
+ it('passes the correct callback context', () => {
261
var container = document.createElement('div');
262
var calls = 0;
263
@@ -297,7 +297,7 @@ describe('ReactMount', function() {
297
expect(calls).toBe(5);
298
});
299
300
- it('tracks root instances', function() {
300
+ it('tracks root instances', () => {
301
// Used by devtools.
302
expect(Object.keys(ReactMount._instancesByReactRootID).length).toBe(0);
303
ReactTestUtils.renderIntoDocument(<span />);
@@ -309,7 +309,7 @@ describe('ReactMount', function() {
309
expect(Object.keys(ReactMount._instancesByReactRootID).length).toBe(1);
310
});
311
312
- it('marks top-level mounts', function() {
312
+ it('marks top-level mounts', () => {
313
var ReactFeatureFlags = require('ReactFeatureFlags');
314
315
class Foo extends React.Component {
src/renderers/dom/client/__tests__/ReactMountDestruction-test.js
+4
-4
@@ -14,8 +14,8 @@
14
var React = require('React');
15
var ReactDOM = require('ReactDOM');
16
17
-describe('ReactMount', function() {
18
- it('should destroy a react root upon request', function() {
17
+describe('ReactMount', () => {
18
+ it('should destroy a react root upon request', () => {
19
var mainContainerDiv = document.createElement('div');
20
document.body.appendChild(mainContainerDiv);
21
@@ -40,7 +40,7 @@ describe('ReactMount', function() {
40
expect(secondRootDiv.firstChild).toBeNull();
41
});
42
43
- it('should warn when unmounting a non-container root node', function() {
43
+ it('should warn when unmounting a non-container root node', () => {
44
var mainContainerDiv = document.createElement('div');
45
46
var component =
@@ -62,7 +62,7 @@ describe('ReactMount', function() {
62
);
63
});
64
65
- it('should warn when unmounting a non-container, non-root node', function() {
65
+ it('should warn when unmounting a non-container, non-root node', () => {
66
var mainContainerDiv = document.createElement('div');
67
68
var component =
src/renderers/dom/client/__tests__/ReactRenderDocument-test.js
+9
-9
@@ -26,8 +26,8 @@ var UNMOUNT_INVARIANT_MESSAGE =
26
'efficiently. To fix this, have a single top-level component that ' +
27
'never unmounts render these elements.';
28
29
-describe('rendering React components at document', function() {
30
- beforeEach(function() {
29
+describe('rendering React components at document', () => {
30
+ beforeEach(() => {
31
jest.resetModuleRegistry();
32
33
React = require('React');
@@ -38,7 +38,7 @@ describe('rendering React components at document', function() {
38
testDocument = getTestDocument();
39
});
40
41
- it('should be able to adopt server markup', function() {
41
+ it('should be able to adopt server markup', () => {
42
expect(testDocument).not.toBeUndefined();
43
44
class Root extends React.Component {
@@ -69,7 +69,7 @@ describe('rendering React components at document', function() {
69
expect(body).toBe(testDocument.body);
70
});
71
72
- it('should not be able to unmount component from document node', function() {
72
+ it('should not be able to unmount component from document node', () => {
73
expect(testDocument).not.toBeUndefined();
74
75
class Root extends React.Component {
@@ -99,7 +99,7 @@ describe('rendering React components at document', function() {
99
expect(testDocument.body.innerHTML).toBe('Hello world');
100
});
101
102
- it('should not be able to switch root constructors', function() {
102
+ it('should not be able to switch root constructors', () => {
103
expect(testDocument).not.toBeUndefined();
104
105
class Component extends React.Component {
@@ -147,7 +147,7 @@ describe('rendering React components at document', function() {
147
expect(testDocument.body.innerHTML).toBe('Hello world');
148
});
149
150
- it('should be able to mount into document', function() {
150
+ it('should be able to mount into document', () => {
151
expect(testDocument).not.toBeUndefined();
152
153
class Component extends React.Component {
@@ -175,7 +175,7 @@ describe('rendering React components at document', function() {
175
expect(testDocument.body.innerHTML).toBe('Hello world');
176
});
177
178
- it('should give helpful errors on state desync', function() {
178
+ it('should give helpful errors on state desync', () => {
179
expect(testDocument).not.toBeUndefined();
180
181
class Component extends React.Component {
@@ -215,7 +215,7 @@ describe('rendering React components at document', function() {
215
);
216
});
217
218
- it('should throw on full document render w/ no markup', function() {
218
+ it('should throw on full document render w/ no markup', () => {
219
expect(testDocument).not.toBeUndefined();
220
221
var container = testDocument;
@@ -245,7 +245,7 @@ describe('rendering React components at document', function() {
245
);
246
});
247
248
- it('supports findDOMNode on full-page components', function() {
248
+ it('supports findDOMNode on full-page components', () => {
249
var tree =
250
<html>
251
<head>
src/renderers/dom/client/__tests__/findDOMNode-test.js
+6
-6
@@ -15,12 +15,12 @@ var React = require('React');
15
var ReactDOM = require('ReactDOM');
16
var ReactTestUtils = require('ReactTestUtils');
17
18
-describe('findDOMNode', function() {
19
- it('findDOMNode should return null if passed null', function() {
18
+describe('findDOMNode', () => {
19
+ it('findDOMNode should return null if passed null', () => {
20
expect(ReactDOM.findDOMNode(null)).toBe(null);
21
});
22
23
- it('findDOMNode should find dom element', function() {
23
+ it('findDOMNode should find dom element', () => {
24
class MyNode extends React.Component {
25
render() {
26
return <div><span>Noise</span></div>;
@@ -34,7 +34,7 @@ describe('findDOMNode', function() {
34
expect(mySameDiv).toBe(myDiv);
35
});
36
37
- it('findDOMNode should reject random objects', function() {
37
+ it('findDOMNode should reject random objects', () => {
38
expect(function() {
39
ReactDOM.findDOMNode({foo: 'bar'});
40
}).toThrowError(
@@ -42,7 +42,7 @@ describe('findDOMNode', function() {
42
);
43
});
44
45
- it('findDOMNode should reject unmounted objects with render func', function() {
45
+ it('findDOMNode should reject unmounted objects with render func', () => {
46
class Foo extends React.Component {
47
render() {
48
return <div />;
@@ -58,7 +58,7 @@ describe('findDOMNode', function() {
58
);
59
});
60
61
- it('findDOMNode should not throw an error when called within a component that is not mounted', function() {
61
+ it('findDOMNode should not throw an error when called within a component that is not mounted', () => {
62
class Bar extends React.Component {
63
componentWillMount() {
64
expect(ReactDOM.findDOMNode(this)).toBeNull();
src/renderers/dom/client/__tests__/inputValueTracking-test.js
+15
-15
@@ -14,10 +14,10 @@ var React = require('React');
14
var ReactTestUtils = require('ReactTestUtils');
15
var inputValueTracking = require('inputValueTracking');
16
17
-describe('inputValueTracking', function() {
17
+describe('inputValueTracking', () => {
18
var input, checkbox, mockComponent;
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
input = document.createElement('input');
22
input.type = 'text';
23
checkbox = document.createElement('input');
@@ -25,7 +25,7 @@ describe('inputValueTracking', function() {
25
mockComponent = { _hostNode: input, _wrapperState: {} };
26
});
27
28
- it('should attach tracker to wrapper state', function() {
28
+ it('should attach tracker to wrapper state', () => {
29
inputValueTracking.track(mockComponent);
30
31
expect(
@@ -33,7 +33,7 @@ describe('inputValueTracking', function() {
33
).toBe(true);
34
});
35
36
- it('should define `value` on the instance node', function() {
36
+ it('should define `value` on the instance node', () => {
37
inputValueTracking.track(mockComponent);
38
39
expect(
@@ -41,14 +41,14 @@ describe('inputValueTracking', function() {
41
).toBe(true);
42
});
43
44
- it('should define `checked` on the instance node', function() {
44
+ it('should define `checked` on the instance node', () => {
45
mockComponent._hostNode = checkbox;
46
inputValueTracking.track(mockComponent);
47
48
expect(checkbox.hasOwnProperty('checked')).toBe(true);
49
});
50
51
- it('should initialize with the current value', function() {
51
+ it('should initialize with the current value', () => {
52
input.value ='foo';
53
54
inputValueTracking.track(mockComponent);
@@ -58,7 +58,7 @@ describe('inputValueTracking', function() {
58
expect(tracker.getValue()).toEqual('foo');
59
});
60
61
- it('should initialize with the current `checked`', function() {
61
+ it('should initialize with the current `checked`', () => {
62
mockComponent._hostNode = checkbox;
63
checkbox.checked = true;
64
inputValueTracking.track(mockComponent);
@@ -68,7 +68,7 @@ describe('inputValueTracking', function() {
68
expect(tracker.getValue()).toEqual('true');
69
});
70
71
- it('should track value changes', function() {
71
+ it('should track value changes', () => {
72
input.value ='foo';
73
74
inputValueTracking.track(mockComponent);
@@ -79,7 +79,7 @@ describe('inputValueTracking', function() {
79
expect(tracker.getValue()).toEqual('bar');
80
});
81
82
- it('should tracked`checked` changes', function() {
82
+ it('should tracked`checked` changes', () => {
83
mockComponent._hostNode = checkbox;
84
checkbox.checked = true;
85
inputValueTracking.track(mockComponent);
@@ -90,7 +90,7 @@ describe('inputValueTracking', function() {
90
expect(tracker.getValue()).toEqual('false');
91
});
92
93
- it('should update value manually', function() {
93
+ it('should update value manually', () => {
94
input.value ='foo';
95
inputValueTracking.track(mockComponent);
96
@@ -100,7 +100,7 @@ describe('inputValueTracking', function() {
100
expect(tracker.getValue()).toEqual('bar');
101
});
102
103
- it('should coerce value to a string', function() {
103
+ it('should coerce value to a string', () => {
104
input.value ='foo';
105
inputValueTracking.track(mockComponent);
106
@@ -110,7 +110,7 @@ describe('inputValueTracking', function() {
110
expect(tracker.getValue()).toEqual('500');
111
});
112
113
- it('should update value if it changed and return result', function() {
113
+ it('should update value if it changed and return result', () => {
114
inputValueTracking.track(mockComponent);
115
input.value ='foo';
116
@@ -129,7 +129,7 @@ describe('inputValueTracking', function() {
129
expect(tracker.getValue()).toEqual('foo');
130
});
131
132
- it('should track value and return true when updating untracked instance', function() {
132
+ it('should track value and return true when updating untracked instance', () => {
133
input.value ='foo';
134
135
expect(
@@ -141,13 +141,13 @@ describe('inputValueTracking', function() {
141
expect(tracker.getValue()).toEqual('foo');
142
});
143
144
- it('should return tracker from node', function() {
144
+ it('should return tracker from node', () => {
145
var node = ReactTestUtils.renderIntoDocument(<input type="text" defaultValue="foo" />);
146
var tracker = inputValueTracking._getTrackerFromNode(node);
147
expect(tracker.getValue()).toEqual('foo');
148
});
149
150
- it('should stop tracking', function() {
150
+ it('should stop tracking', () => {
151
inputValueTracking.track(mockComponent);
152
153
expect(
src/renderers/dom/client/__tests__/validateDOMNesting-test.js
+5
-5
@@ -45,14 +45,14 @@ function isTagStackValid(stack) {
45
return true;
46
}
47
48
-describe('ReactContextValidator', function() {
49
- beforeEach(function() {
48
+describe('ReactContextValidator', () => {
49
+ beforeEach(() => {
50
jest.resetModuleRegistry();
51
52
validateDOMNesting = require('validateDOMNesting');
53
});
54
55
- it('allows any tag with no context', function() {
55
+ it('allows any tag with no context', () => {
56
// With renderToString (for example), we don't know where we're mounting the
57
// tag so we must err on the side of leniency.
58
var allTags = [].concat(specialTags, formattingTags, ['mysterytag']);
@@ -61,7 +61,7 @@ describe('ReactContextValidator', function() {
61
});
62
});
63
64
- it('allows valid nestings', function() {
64
+ it('allows valid nestings', () => {
65
expect(isTagStackValid(['table', 'tbody', 'tr', 'td', 'b'])).toBe(true);
66
expect(isTagStackValid(['body', 'datalist', 'option'])).toBe(true);
67
expect(isTagStackValid(['div', 'a', 'object', 'a'])).toBe(true);
@@ -76,7 +76,7 @@ describe('ReactContextValidator', function() {
76
expect(isTagStackValid(['div', 'ul', 'li', 'dd', 'li'])).toBe(true);
77
});
78
79
- it('prevents problematic nestings', function() {
79
+ it('prevents problematic nestings', () => {
80
expect(isTagStackValid(['a', 'a'])).toBe(false);
81
expect(isTagStackValid(['form', 'form'])).toBe(false);
82
expect(isTagStackValid(['p', 'p'])).toBe(false);
src/renderers/dom/client/eventPlugins/__tests__/ChangeEventPlugin-test.js
+10
-10
@@ -39,8 +39,8 @@ function setUntrackedValue(elem, value) {
39
tracker.setValue(current);
40
}
41
42
-describe('ChangeEventPlugin', function() {
43
- it('should fire change for checkbox input', function() {
42
+describe('ChangeEventPlugin', () => {
43
+ it('should fire change for checkbox input', () => {
44
var called = 0;
45
46
function cb(e) {
@@ -56,7 +56,7 @@ describe('ChangeEventPlugin', function() {
56
expect(called).toBe(1);
57
});
58
59
- it('should catch setting the value programmatically', function() {
59
+ it('should catch setting the value programmatically', () => {
60
var input = ReactTestUtils.renderIntoDocument(
61
<input type="text" defaultValue="foo"/>
62
);
@@ -65,7 +65,7 @@ describe('ChangeEventPlugin', function() {
65
expect(getTrackedValue(input)).toBe('bar');
66
});
67
68
- it('should not fire change when setting the value programmatically', function() {
68
+ it('should not fire change when setting the value programmatically', () => {
69
var called = 0;
70
71
function cb(e) {
@@ -87,7 +87,7 @@ describe('ChangeEventPlugin', function() {
87
expect(called).toBe(1);
88
});
89
90
- it('should not fire change when setting checked programmatically', function() {
90
+ it('should not fire change when setting checked programmatically', () => {
91
var called = 0;
92
93
function cb(e) {
@@ -110,14 +110,14 @@ describe('ChangeEventPlugin', function() {
110
expect(called).toBe(1);
111
});
112
113
- it('should unmount', function() {
113
+ it('should unmount', () => {
114
var container = document.createElement('div');
115
var input = ReactDOM.render(<input />, container);
116
117
ReactDOM.unmountComponentAtNode(container);
118
});
119
120
- it('should only fire change for checked radio button once', function() {
120
+ it('should only fire change for checked radio button once', () => {
121
var called = 0;
122
123
function cb(e) {
@@ -131,7 +131,7 @@ describe('ChangeEventPlugin', function() {
131
expect(called).toBe(1);
132
});
133
134
- it('should deduplicate input value change events', function() {
134
+ it('should deduplicate input value change events', () => {
135
var input;
136
var called = 0;
137
@@ -169,7 +169,7 @@ describe('ChangeEventPlugin', function() {
169
});
170
});
171
172
- it('should listen for both change and input events when supported', function() {
172
+ it('should listen for both change and input events when supported', () => {
173
var called = 0;
174
175
function cb(e) {
@@ -193,7 +193,7 @@ describe('ChangeEventPlugin', function() {
193
expect(called).toBe(2);
194
});
195
196
- it('should only fire events when the value changes for range inputs', function() {
196
+ it('should only fire events when the value changes for range inputs', () => {
197
var called = 0;
198
199
function cb(e) {
src/renderers/dom/client/eventPlugins/__tests__/EnterLeaveEventPlugin-test.js
+3
-3
@@ -16,8 +16,8 @@ var React;
16
var ReactDOM;
17
var ReactDOMComponentTree;
18
19
-describe('EnterLeaveEventPlugin', function() {
20
- beforeEach(function() {
19
+describe('EnterLeaveEventPlugin', () => {
20
+ beforeEach(() => {
21
jest.resetModuleRegistry();
22
23
EnterLeaveEventPlugin = require('EnterLeaveEventPlugin');
@@ -26,7 +26,7 @@ describe('EnterLeaveEventPlugin', function() {
26
ReactDOMComponentTree = require('ReactDOMComponentTree');
27
});
28
29
- it('should set relatedTarget properly in iframe', function() {
29
+ it('should set relatedTarget properly in iframe', () => {
30
var iframe = document.createElement('iframe');
31
document.body.appendChild(iframe);
32
src/renderers/dom/client/eventPlugins/__tests__/FallbackCompositionState-test.js
+11
-11
@@ -11,12 +11,12 @@
11
12
'use strict';
13
14
-describe('FallbackCompositionState', function() {
14
+describe('FallbackCompositionState', () => {
15
var FallbackCompositionState;
16
17
var TEXT = 'Hello world';
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
FallbackCompositionState = require('FallbackCompositionState');
21
});
22
@@ -48,7 +48,7 @@ describe('FallbackCompositionState', function() {
48
FallbackCompositionState.release(composition);
49
}
50
51
- it('extracts value via `getText()`', function() {
51
+ it('extracts value via `getText()`', () => {
52
var composition = FallbackCompositionState.getPooled(getInput());
53
expect(composition.getText()).toBe(TEXT);
54
FallbackCompositionState.release(composition);
@@ -62,30 +62,30 @@ describe('FallbackCompositionState', function() {
62
FallbackCompositionState.release(composition);
63
});
64
65
- describe('Extract fallback data inserted at collapsed cursor', function() {
66
- it('extracts when inserted at start of text', function() {
65
+ describe('Extract fallback data inserted at collapsed cursor', () => {
66
+ it('extracts when inserted at start of text', () => {
67
assertExtractedData('XXXHello world', 'XXX');
68
});
69
70
- it('extracts when inserted within text', function() {
70
+ it('extracts when inserted within text', () => {
71
assertExtractedData('Hello XXXworld', 'XXX');
72
});
73
74
- it('extracts when inserted at end of text', function() {
74
+ it('extracts when inserted at end of text', () => {
75
assertExtractedData('Hello worldXXX', 'XXX');
76
});
77
});
78
79
- describe('Extract fallback data for non-collapsed range', function() {
80
- it('extracts when inserted at start of text', function() {
79
+ describe('Extract fallback data for non-collapsed range', () => {
80
+ it('extracts when inserted at start of text', () => {
81
assertExtractedData('XXX world', 'XXX');
82
});
83
84
- it('extracts when inserted within text', function() {
84
+ it('extracts when inserted within text', () => {
85
assertExtractedData('HelXXXrld', 'XXX');
86
});
87
88
- it('extracts when inserted at end of text', function() {
88
+ it('extracts when inserted at end of text', () => {
89
assertExtractedData('Hello XXX', 'XXX');
90
});
91
});
src/renderers/dom/client/eventPlugins/__tests__/SelectEventPlugin-test.js
+4
-4
@@ -17,7 +17,7 @@ var ReactDOMComponentTree;
17
var ReactTestUtils;
18
var SelectEventPlugin;
19
20
-describe('SelectEventPlugin', function() {
20
+describe('SelectEventPlugin', () => {
21
function extract(node, topLevelEvent) {
22
return SelectEventPlugin.extractEvents(
23
topLevelEvent,
@@ -27,7 +27,7 @@ describe('SelectEventPlugin', function() {
27
);
28
}
29
30
- beforeEach(function() {
30
+ beforeEach(() => {
31
React = require('React');
32
ReactDOM = require('ReactDOM');
33
ReactDOMComponentTree = require('ReactDOMComponentTree');
@@ -35,7 +35,7 @@ describe('SelectEventPlugin', function() {
35
SelectEventPlugin = require('SelectEventPlugin');
36
});
37
38
- it('should skip extraction if no listeners are present', function() {
38
+ it('should skip extraction if no listeners are present', () => {
39
class WithoutSelect extends React.Component {
40
render() {
41
return <input type="text" />;
@@ -53,7 +53,7 @@ describe('SelectEventPlugin', function() {
53
expect(mouseup).toBe(null);
54
});
55
56
- it('should extract if an `onSelect` listener is present', function() {
56
+ it('should extract if an `onSelect` listener is present', () => {
57
class WithSelect extends React.Component {
58
render() {
59
return <input type="text" onSelect={this.props.onSelect} />;
src/renderers/dom/client/syntheticEvents/__tests__/SyntheticClipboardEvent-test.js
+10
-10
@@ -13,10 +13,10 @@
13
14
var SyntheticClipboardEvent;
15
16
-describe('SyntheticClipboardEvent', function() {
16
+describe('SyntheticClipboardEvent', () => {
17
var createEvent;
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
SyntheticClipboardEvent = require('SyntheticClipboardEvent');
21
createEvent = function(nativeEvent) {
22
var target = require('getEventTarget')(nativeEvent);
@@ -24,10 +24,10 @@ describe('SyntheticClipboardEvent', function() {
24
};
25
});
26
27
- describe('ClipboardEvent interface', function() {
28
- describe('clipboardData', function() {
29
- describe('when event has clipboardData', function() {
30
- it("returns event's clipboardData", function() {
27
+ describe('ClipboardEvent interface', () => {
28
+ describe('clipboardData', () => {
29
+ describe('when event has clipboardData', () => {
30
+ it("returns event's clipboardData", () => {
31
// Mock clipboardData since native implementation doesn't have a constructor
32
var clipboardData = jasmine.createSpyObj(
33
'clipboardData',
@@ -41,8 +41,8 @@ describe('SyntheticClipboardEvent', function() {
41
});
42
});
43
44
- describe('EventInterface', function() {
45
- it('normalizes properties from the Event interface', function() {
44
+ describe('EventInterface', () => {
45
+ it('normalizes properties from the Event interface', () => {
46
var target = document.createElement('div');
47
var syntheticEvent = createEvent({srcElement: target});
48
@@ -50,7 +50,7 @@ describe('SyntheticClipboardEvent', function() {
50
expect(syntheticEvent.type).toBe(undefined);
51
});
52
53
- it('is able to `preventDefault` and `stopPropagation`', function() {
53
+ it('is able to `preventDefault` and `stopPropagation`', () => {
54
var nativeEvent = {};
55
var syntheticEvent = createEvent(nativeEvent);
56
@@ -63,7 +63,7 @@ describe('SyntheticClipboardEvent', function() {
63
expect(syntheticEvent.isPropagationStopped()).toBe(true);
64
});
65
66
- it('is able to `persist`', function() {
66
+ it('is able to `persist`', () => {
67
var syntheticEvent = createEvent({});
68
69
expect(syntheticEvent.isPersistent()).toBe(false);
src/renderers/dom/client/syntheticEvents/__tests__/SyntheticEvent-test.js
+13
-13
@@ -16,10 +16,10 @@ var React;
16
var ReactDOM;
17
var ReactTestUtils;
18
19
-describe('SyntheticEvent', function() {
19
+describe('SyntheticEvent', () => {
20
var createEvent;
21
22
- beforeEach(function() {
22
+ beforeEach(() => {
23
SyntheticEvent = require('SyntheticEvent');
24
React = require('React');
25
ReactDOM = require('ReactDOM');
@@ -31,7 +31,7 @@ describe('SyntheticEvent', function() {
31
};
32
});
33
34
- it('should normalize `target` from the nativeEvent', function() {
34
+ it('should normalize `target` from the nativeEvent', () => {
35
var target = document.createElement('div');
36
var syntheticEvent = createEvent({srcElement: target});
37
@@ -39,7 +39,7 @@ describe('SyntheticEvent', function() {
39
expect(syntheticEvent.type).toBe(undefined);
40
});
41
42
- it('should be able to `preventDefault`', function() {
42
+ it('should be able to `preventDefault`', () => {
43
var nativeEvent = {};
44
var syntheticEvent = createEvent(nativeEvent);
45
@@ -52,14 +52,14 @@ describe('SyntheticEvent', function() {
52
expect(nativeEvent.returnValue).toBe(false);
53
});
54
55
- it('should be prevented if nativeEvent is prevented', function() {
55
+ it('should be prevented if nativeEvent is prevented', () => {
56
expect(
57
createEvent({defaultPrevented: true}).isDefaultPrevented()
58
).toBe(true);
59
expect(createEvent({returnValue: false}).isDefaultPrevented()).toBe(true);
60
});
61
62
- it('should be able to `stopPropagation`', function() {
62
+ it('should be able to `stopPropagation`', () => {
63
var nativeEvent = {};
64
var syntheticEvent = createEvent(nativeEvent);
65
@@ -70,7 +70,7 @@ describe('SyntheticEvent', function() {
70
expect(nativeEvent.cancelBubble).toBe(true);
71
});
72
73
- it('should be able to `persist`', function() {
73
+ it('should be able to `persist`', () => {
74
var syntheticEvent = createEvent({});
75
76
expect(syntheticEvent.isPersistent()).toBe(false);
@@ -78,7 +78,7 @@ describe('SyntheticEvent', function() {
78
expect(syntheticEvent.isPersistent()).toBe(true);
79
});
80
81
- it('should be nullified if the synthetic event has called destructor and log warnings', function() {
81
+ it('should be nullified if the synthetic event has called destructor and log warnings', () => {
82
spyOn(console, 'error');
83
var target = document.createElement('div');
84
var syntheticEvent = createEvent({srcElement: target});
@@ -98,7 +98,7 @@ describe('SyntheticEvent', function() {
98
);
99
});
100
101
- it('should warn when setting properties of a destructored synthetic event', function() {
101
+ it('should warn when setting properties of a destructored synthetic event', () => {
102
spyOn(console, 'error');
103
var target = document.createElement('div');
104
var syntheticEvent = createEvent({srcElement: target});
@@ -114,7 +114,7 @@ describe('SyntheticEvent', function() {
114
);
115
});
116
117
- it('should warn if the synthetic event has been released when calling `preventDefault`', function() {
117
+ it('should warn if the synthetic event has been released when calling `preventDefault`', () => {
118
spyOn(console, 'error');
119
var syntheticEvent = createEvent({});
120
SyntheticEvent.release(syntheticEvent);
@@ -129,7 +129,7 @@ describe('SyntheticEvent', function() {
129
);
130
});
131
132
- it('should warn if the synthetic event has been released when calling `stopPropagation`', function() {
132
+ it('should warn if the synthetic event has been released when calling `stopPropagation`', () => {
133
spyOn(console, 'error');
134
var syntheticEvent = createEvent({});
135
SyntheticEvent.release(syntheticEvent);
@@ -147,7 +147,7 @@ describe('SyntheticEvent', function() {
147
// TODO: reenable this test. We are currently silencing these warnings when
148
// using TestUtils.Simulate to avoid spurious warnings that result from the
149
// way we simulate events.
150
- xit('should properly log warnings when events simulated with rendered components', function() {
150
+ xit('should properly log warnings when events simulated with rendered components', () => {
151
spyOn(console, 'error');
152
var event;
153
var element = document.createElement('div');
@@ -171,7 +171,7 @@ describe('SyntheticEvent', function() {
171
);
172
});
173
174
- it('should warn if Proxy is supported and the synthetic event is added a property', function() {
174
+ it('should warn if Proxy is supported and the synthetic event is added a property', () => {
175
spyOn(console, 'error');
176
var syntheticEvent = createEvent({});
177
syntheticEvent.foo = 'bar';
src/renderers/dom/client/syntheticEvents/__tests__/SyntheticKeyboardEvent-test.js
+24
-24
@@ -14,10 +14,10 @@
14
var SyntheticKeyboardEvent;
15
var getEventCharCode;
16
17
-describe('SyntheticKeyboardEvent', function() {
17
+describe('SyntheticKeyboardEvent', () => {
18
var createEvent;
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
// Mock getEventCharCode for proper unit testing
22
jest.mock('getEventCharCode');
23
getEventCharCode = require('getEventCharCode');
@@ -29,10 +29,10 @@ describe('SyntheticKeyboardEvent', function() {
29
};
30
});
31
32
- describe('KeyboardEvent interface', function() {
33
- describe('charCode', function() {
34
- describe('when event is `keypress`', function() {
35
- it('returns whatever getEventCharCode returns', function() {
32
+ describe('KeyboardEvent interface', () => {
33
+ describe('charCode', () => {
34
+ describe('when event is `keypress`', () => {
35
+ it('returns whatever getEventCharCode returns', () => {
36
getEventCharCode.mockReturnValue(100500);
37
var keyboardEvent = createEvent({type: 'keypress', charCode: 50});
38
@@ -40,33 +40,33 @@ describe('SyntheticKeyboardEvent', function() {
40
});
41
});
42
43
- describe('when event is not `keypress`', function() {
44
- it('returns 0', function() {
43
+ describe('when event is not `keypress`', () => {
44
+ it('returns 0', () => {
45
var keyboardEvent = createEvent({type: 'keyup', charCode: 50});
46
expect(keyboardEvent.charCode).toBe(0);
47
});
48
});
49
});
50
51
- describe('keyCode', function() {
52
- describe('when event is `keydown` or `keyup`', function() {
53
- it('returns a passed keyCode', function() {
51
+ describe('keyCode', () => {
52
+ describe('when event is `keydown` or `keyup`', () => {
53
+ it('returns a passed keyCode', () => {
54
var keyboardEvent = createEvent({type: 'keyup', keyCode: 40});
55
expect(keyboardEvent.keyCode).toBe(40);
56
});
57
});
58
59
- describe('when event is `keypress`', function() {
60
- it('returns 0', function() {
59
+ describe('when event is `keypress`', () => {
60
+ it('returns 0', () => {
61
var keyboardEvent = createEvent({type: 'keypress', charCode: 40});
62
expect(keyboardEvent.keyCode).toBe(0);
63
});
64
});
65
});
66
67
- describe('which', function() {
68
- describe('when event is `keypress`', function() {
69
- it('returns whatever getEventCharCode returns', function() {
67
+ describe('which', () => {
68
+ describe('when event is `keypress`', () => {
69
+ it('returns whatever getEventCharCode returns', () => {
70
getEventCharCode.mockReturnValue(9001);
71
var keyboardEvent = createEvent({type: 'keypress', charCode: 50});
72
@@ -74,15 +74,15 @@ describe('SyntheticKeyboardEvent', function() {
74
});
75
});
76
77
- describe('when event is `keydown` or `keyup`', function() {
78
- it('returns a passed keyCode', function() {
77
+ describe('when event is `keydown` or `keyup`', () => {
78
+ it('returns a passed keyCode', () => {
79
var keyboardEvent = createEvent({type: 'keyup', keyCode: 40});
80
expect(keyboardEvent.which).toBe(40);
81
});
82
});
83
84
- describe('when event type is unknown', function() {
85
- it('returns 0', function() {
84
+ describe('when event type is unknown', () => {
85
+ it('returns 0', () => {
86
var keyboardEvent = createEvent({type: 'keysmack', keyCode: 40});
87
expect(keyboardEvent.which).toBe(0);
88
});
@@ -90,8 +90,8 @@ describe('SyntheticKeyboardEvent', function() {
90
});
91
});
92
93
- describe('EventInterface', function() {
94
- it('normalizes properties from the Event interface', function() {
93
+ describe('EventInterface', () => {
94
+ it('normalizes properties from the Event interface', () => {
95
var target = document.createElement('div');
96
var syntheticEvent = createEvent({srcElement: target});
97
@@ -99,7 +99,7 @@ describe('SyntheticKeyboardEvent', function() {
99
expect(syntheticEvent.type).toBe(undefined);
100
});
101
102
- it('is able to `preventDefault` and `stopPropagation`', function() {
102
+ it('is able to `preventDefault` and `stopPropagation`', () => {
103
var nativeEvent = {};
104
var syntheticEvent = createEvent(nativeEvent);
105
@@ -112,7 +112,7 @@ describe('SyntheticKeyboardEvent', function() {
112
expect(syntheticEvent.isPropagationStopped()).toBe(true);
113
});
114
115
- it('is able to `persist`', function() {
115
+ it('is able to `persist`', () => {
116
var syntheticEvent = createEvent({});
117
118
expect(syntheticEvent.isPersistent()).toBe(false);
src/renderers/dom/client/syntheticEvents/__tests__/SyntheticWheelEvent-test.js
+7
-7
@@ -13,10 +13,10 @@
13
14
var SyntheticWheelEvent;
15
16
-describe('SyntheticWheelEvent', function() {
16
+describe('SyntheticWheelEvent', () => {
17
var createEvent;
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
SyntheticWheelEvent = require('SyntheticWheelEvent');
21
22
createEvent = function(nativeEvent) {
@@ -25,7 +25,7 @@ describe('SyntheticWheelEvent', function() {
25
};
26
});
27
28
- it('should normalize properties from the Event interface', function() {
28
+ it('should normalize properties from the Event interface', () => {
29
var target = document.createElement('div');
30
var syntheticEvent = createEvent({srcElement: target});
31
@@ -33,11 +33,11 @@ describe('SyntheticWheelEvent', function() {
33
expect(syntheticEvent.type).toBe(undefined);
34
});
35
36
- it('should normalize properties from the MouseEvent interface', function() {
36
+ it('should normalize properties from the MouseEvent interface', () => {
37
expect(createEvent({which: 2, button: 1}).button).toBe(1);
38
});
39
40
- it('should normalize properties from the WheelEvent interface', function() {
40
+ it('should normalize properties from the WheelEvent interface', () => {
41
var standardEvent = createEvent({deltaX: 10, deltaY: -50});
42
expect(standardEvent.deltaX).toBe(10);
43
expect(standardEvent.deltaY).toBe(-50);
@@ -47,7 +47,7 @@ describe('SyntheticWheelEvent', function() {
47
expect(webkitEvent.deltaY).toBe(-50);
48
});
49
50
- it('should be able to `preventDefault` and `stopPropagation`', function() {
50
+ it('should be able to `preventDefault` and `stopPropagation`', () => {
51
var nativeEvent = {};
52
var syntheticEvent = createEvent(nativeEvent);
53
@@ -60,7 +60,7 @@ describe('SyntheticWheelEvent', function() {
60
expect(syntheticEvent.isPropagationStopped()).toBe(true);
61
});
62
63
- it('should be able to `persist`', function() {
63
+ it('should be able to `persist`', () => {
64
var syntheticEvent = createEvent({});
65
66
expect(syntheticEvent.isPersistent()).toBe(false);
src/renderers/dom/client/utils/__tests__/getEventCharCode-test.js
+20
-20
@@ -13,10 +13,10 @@
13
14
var getEventCharCode = require('getEventCharCode');
15
16
-describe('getEventCharCode', function() {
17
- describe('when charCode is present in nativeEvent', function() {
18
- describe('when charCode is 0 and keyCode is 13', function() {
19
- it('returns 13', function() {
16
+describe('getEventCharCode', () => {
17
+ describe('when charCode is present in nativeEvent', () => {
18
+ describe('when charCode is 0 and keyCode is 13', () => {
19
+ it('returns 13', () => {
20
var nativeEvent = new KeyboardEvent(
21
'keypress', {charCode: 0, keyCode: 13}
22
);
@@ -25,26 +25,26 @@ describe('getEventCharCode', function() {
25
});
26
});
27
28
- describe('when charCode is not 0 and/or keyCode is not 13', function() {
29
- describe('when charCode is 32 or bigger', function() {
30
- it('returns charCode', function() {
28
+ describe('when charCode is not 0 and/or keyCode is not 13', () => {
29
+ describe('when charCode is 32 or bigger', () => {
30
+ it('returns charCode', () => {
31
var nativeEvent = new KeyboardEvent('keypress', {charCode: 32});
32
33
expect(getEventCharCode(nativeEvent)).toBe(32);
34
});
35
});
36
37
- describe('when charCode is smaller than 32', function() {
38
- describe('when charCode is 13', function() {
39
- it('returns 13', function() {
37
+ describe('when charCode is smaller than 32', () => {
38
+ describe('when charCode is 13', () => {
39
+ it('returns 13', () => {
40
var nativeEvent = new KeyboardEvent('keypress', {charCode: 13});
41
42
expect(getEventCharCode(nativeEvent)).toBe(13);
43
});
44
});
45
46
- describe('when charCode is not 13', function() {
47
- it('returns 0', function() {
46
+ describe('when charCode is not 13', () => {
47
+ it('returns 0', () => {
48
var nativeEvent = new KeyboardEvent('keypress', {charCode: 31});
49
50
expect(getEventCharCode(nativeEvent)).toBe(0);
@@ -59,26 +59,26 @@ describe('getEventCharCode', function() {
59
KeyboardEvent's 'charCode' event key cannot be deleted to simulate a missing
60
charCode key.
61
*/
62
- describe('when charCode is not present in nativeEvent', function() {
63
- describe('when keyCode is 32 or bigger', function() {
64
- it('returns keyCode', function() {
62
+ describe('when charCode is not present in nativeEvent', () => {
63
+ describe('when keyCode is 32 or bigger', () => {
64
+ it('returns keyCode', () => {
65
var nativeEvent = {'keyCode': 32};
66
67
expect(getEventCharCode(nativeEvent)).toBe(32);
68
});
69
});
70
71
- describe('when keyCode is smaller than 32', function() {
72
- describe('when keyCode is 13', function() {
73
- it('returns 13', function() {
71
+ describe('when keyCode is smaller than 32', () => {
72
+ describe('when keyCode is 13', () => {
73
+ it('returns 13', () => {
74
var nativeEvent = {'keyCode': 13};
75
76
expect(getEventCharCode(nativeEvent)).toBe(13);
77
});
78
});
79
80
- describe('when keyCode is not 13', function() {
81
- it('returns 0', function() {
80
+ describe('when keyCode is not 13', () => {
81
+ it('returns 0', () => {
82
var nativeEvent = {'keyCode': 31};
83
84
expect(getEventCharCode(nativeEvent)).toBe(0);
src/renderers/dom/client/utils/__tests__/getEventKey-test.js
+19
-19
@@ -13,18 +13,18 @@
13
14
var getEventKey = require('getEventKey');
15
16
-describe('getEventKey', function() {
17
- describe('when key is implemented in a browser', function() {
18
- describe('when key is not normalized', function() {
19
- it('returns a normalized value', function() {
16
+describe('getEventKey', () => {
17
+ describe('when key is implemented in a browser', () => {
18
+ describe('when key is not normalized', () => {
19
+ it('returns a normalized value', () => {
20
var nativeEvent = new KeyboardEvent('keypress', {key: 'Del'});
21
22
expect(getEventKey(nativeEvent)).toBe('Delete');
23
});
24
});
25
26
- describe('when key is normalized', function() {
27
- it('returns a key', function() {
26
+ describe('when key is normalized', () => {
27
+ it('returns a key', () => {
28
var nativeEvent = new KeyboardEvent('keypress', {key: 'f'});
29
30
expect(getEventKey(nativeEvent)).toBe('f');
@@ -32,18 +32,18 @@ describe('getEventKey', function() {
32
});
33
});
34
35
- describe('when key is not implemented in a browser', function() {
36
- describe('when event type is keypress', function() {
37
- describe('when charCode is 13', function() {
38
- it("returns 'Enter'", function() {
35
+ describe('when key is not implemented in a browser', () => {
36
+ describe('when event type is keypress', () => {
37
+ describe('when charCode is 13', () => {
38
+ it("returns 'Enter'", () => {
39
var nativeEvent = new KeyboardEvent('keypress', {charCode: 13});
40
41
expect(getEventKey(nativeEvent)).toBe('Enter');
42
});
43
});
44
45
- describe('when charCode is not 13', function() {
46
- it('returns a string from a charCode', function() {
45
+ describe('when charCode is not 13', () => {
46
+ it('returns a string from a charCode', () => {
47
var nativeEvent = new KeyboardEvent('keypress', {charCode: 65});
48
49
expect(getEventKey(nativeEvent)).toBe('A');
@@ -51,17 +51,17 @@ describe('getEventKey', function() {
51
});
52
});
53
54
- describe('when event type is keydown or keyup', function() {
55
- describe('when keyCode is recognized', function() {
56
- it('returns a translated key', function() {
54
+ describe('when event type is keydown or keyup', () => {
55
+ describe('when keyCode is recognized', () => {
56
+ it('returns a translated key', () => {
57
var nativeEvent = new KeyboardEvent('keydown', {keyCode: 45});
58
59
expect(getEventKey(nativeEvent)).toBe('Insert');
60
});
61
});
62
63
- describe('when keyCode is not recognized', function() {
64
- it('returns Unidentified', function() {
63
+ describe('when keyCode is not recognized', () => {
64
+ it('returns Unidentified', () => {
65
var nativeEvent = new KeyboardEvent('keydown', {keyCode: 1337});
66
67
expect(getEventKey(nativeEvent)).toBe('Unidentified');
@@ -69,8 +69,8 @@ describe('getEventKey', function() {
69
});
70
});
71
72
- describe('when event type is unknown', function() {
73
- it('returns an empty string', function() {
72
+ describe('when event type is unknown', () => {
73
+ it('returns an empty string', () => {
74
var nativeEvent = new KeyboardEvent('keysmack');
75
76
expect(getEventKey(nativeEvent)).toBe('');
src/renderers/dom/client/utils/__tests__/getNodeForCharacterOffset-test.js
+5
-5
@@ -28,22 +28,22 @@ function expectNodeOffset(result, textContent, nodeOffset) {
28
expect(result.offset).toBe(nodeOffset);
29
}
30
31
-describe('getNodeForCharacterOffset', function() {
32
- it('should handle siblings', function() {
31
+describe('getNodeForCharacterOffset', () => {
32
+ it('should handle siblings', () => {
33
var node = createNode('<i>123</i><i>456</i><i>789</i>');
34
35
expectNodeOffset(getNodeForCharacterOffset(node, 0), '123', 0);
36
expectNodeOffset(getNodeForCharacterOffset(node, 4), '456', 1);
37
});
38
39
- it('should handle trailing chars', function() {
39
+ it('should handle trailing chars', () => {
40
var node = createNode('<i>123</i><i>456</i><i>789</i>');
41
42
expectNodeOffset(getNodeForCharacterOffset(node, 3), '123', 3);
43
expectNodeOffset(getNodeForCharacterOffset(node, 9), '789', 3);
44
});
45
46
- it('should handle trees', function() {
46
+ it('should handle trees', () => {
47
var node = createNode(
48
'<i>' +
49
'<i>1</i>' +
@@ -65,7 +65,7 @@ describe('getNodeForCharacterOffset', function() {
65
expect(getNodeForCharacterOffset(node, 10)).toBeUndefined();
66
});
67
68
- it('should handle non-existent offset', function() {
68
+ it('should handle non-existent offset', () => {
69
var node = createNode('<i>123</i>');
70
71
expect(getNodeForCharacterOffset(node, -1)).toBeUndefined();
src/renderers/dom/client/utils/__tests__/setInnerHTML-test.js
+3
-3
@@ -14,9 +14,9 @@
14
var setInnerHTML = require('setInnerHTML');
15
var DOMNamespaces = require('DOMNamespaces');
16
17
-describe('setInnerHTML', function() {
17
+describe('setInnerHTML', () => {
18
describe('when the node has innerHTML property', () => {
19
- it('sets innerHTML on it', function() {
19
+ it('sets innerHTML on it', () => {
20
var node = document.createElement('div');
21
var html = '<h1>hello</h1>';
22
setInnerHTML(node, html);
@@ -27,7 +27,7 @@ describe('setInnerHTML', function() {
27
describe('when the node does not have an innerHTML property', () => {
28
// Disabled. JSDOM doesn't seem to remove nodes when using appendChild to
29
// move existing nodes.
30
- xit('sets innerHTML on it', function() {
30
+ xit('sets innerHTML on it', () => {
31
// Create a mock node that looks like an SVG in IE (without innerHTML)
32
var node = {
33
namespaceURI: DOMNamespaces.svg,
src/renderers/dom/client/wrappers/__tests__/DisabledInputUtil-test.js
+8
-8
@@ -12,7 +12,7 @@
12
'use strict';
13
14
15
-describe('DisabledInputUtils', function() {
15
+describe('DisabledInputUtils', () => {
16
var React;
17
var ReactDOM;
18
var ReactTestUtils;
@@ -40,15 +40,15 @@ describe('DisabledInputUtils', function() {
40
41
elements.forEach(function(tagName) {
42
43
- describe(tagName, function() {
43
+ describe(tagName, () => {
44
45
- beforeEach(function() {
45
+ beforeEach(() => {
46
React = require('React');
47
ReactDOM = require('ReactDOM');
48
ReactTestUtils = require('ReactTestUtils');
49
});
50
51
- it('should forward clicks when it starts out not disabled', function() {
51
+ it('should forward clicks when it starts out not disabled', () => {
52
var element = React.createElement(tagName, {
53
onClick: onClick,
54
});
@@ -56,7 +56,7 @@ describe('DisabledInputUtils', function() {
56
expectClickThru(mounted(element));
57
});
58
59
- it('should not forward clicks when it starts out disabled', function() {
59
+ it('should not forward clicks when it starts out disabled', () => {
60
var element = React.createElement(tagName, {
61
onClick: onClick,
62
disabled: true,
@@ -65,7 +65,7 @@ describe('DisabledInputUtils', function() {
65
expectNoClickThru(mounted(element));
66
});
67
68
- it('should forward clicks when it becomes not disabled', function() {
68
+ it('should forward clicks when it becomes not disabled', () => {
69
var container = document.createElement('div');
70
var element = ReactDOM.render(
71
React.createElement(tagName, { onClick: onClick, disabled: true }),
@@ -78,7 +78,7 @@ describe('DisabledInputUtils', function() {
78
expectClickThru(element);
79
});
80
81
- it('should not forward clicks when it becomes disabled', function() {
81
+ it('should not forward clicks when it becomes disabled', () => {
82
var container = document.createElement('div');
83
var element = ReactDOM.render(
84
React.createElement(tagName, { onClick: onClick }),
@@ -91,7 +91,7 @@ describe('DisabledInputUtils', function() {
91
expectNoClickThru(element);
92
});
93
94
- it('should work correctly if the listener is changed', function() {
94
+ it('should work correctly if the listener is changed', () => {
95
var container = document.createElement('div');
96
var element = ReactDOM.render(
97
React.createElement(tagName, { onClick: onClick, disabled: true }),
src/renderers/dom/client/wrappers/__tests__/ReactDOMIframe-test.js
+3
-3
@@ -11,18 +11,18 @@
11
12
'use strict';
13
14
-describe('ReactDOMIframe', function() {
14
+describe('ReactDOMIframe', () => {
15
var React;
16
var ReactDOM;
17
var ReactTestUtils;
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
React = require('React');
21
ReactDOM = require('ReactDOM');
22
ReactTestUtils = require('ReactTestUtils');
23
});
24
25
- it('should trigger load events', function() {
25
+ it('should trigger load events', () => {
26
var onLoadSpy = jasmine.createSpy();
27
var iframe = React.createElement('iframe', {onLoad: onLoadSpy});
28
iframe = ReactTestUtils.renderIntoDocument(iframe);
src/renderers/dom/client/wrappers/__tests__/ReactDOMInput-test.js
+60
-60
@@ -14,7 +14,7 @@
14
15
var emptyFunction = require('emptyFunction');
16
17
-describe('ReactDOMInput', function() {
17
+describe('ReactDOMInput', () => {
18
var React;
19
var ReactDOM;
20
var ReactDOMServer;
@@ -30,7 +30,7 @@ describe('ReactDOMInput', function() {
30
tracker.setValue(current);
31
}
32
33
- beforeEach(function() {
33
+ beforeEach(() => {
34
jest.resetModuleRegistry();
35
React = require('React');
36
ReactDOM = require('ReactDOM');
@@ -42,7 +42,7 @@ describe('ReactDOMInput', function() {
42
spyOn(console, 'error');
43
});
44
45
- it('should display `defaultValue` of number 0', function() {
45
+ it('should display `defaultValue` of number 0', () => {
46
var stub = <input type="text" defaultValue={0} />;
47
stub = ReactTestUtils.renderIntoDocument(stub);
48
var node = ReactDOM.findDOMNode(stub);
@@ -51,7 +51,7 @@ describe('ReactDOMInput', function() {
51
expect(node.value).toBe('0');
52
});
53
54
- it('should display "true" for `defaultValue` of `true`', function() {
54
+ it('should display "true" for `defaultValue` of `true`', () => {
55
var stub = <input type="text" defaultValue={true} />;
56
stub = ReactTestUtils.renderIntoDocument(stub);
57
var node = ReactDOM.findDOMNode(stub);
@@ -59,7 +59,7 @@ describe('ReactDOMInput', function() {
59
expect(node.value).toBe('true');
60
});
61
62
- it('should display "false" for `defaultValue` of `false`', function() {
62
+ it('should display "false" for `defaultValue` of `false`', () => {
63
var stub = <input type="text" defaultValue={false} />;
64
stub = ReactTestUtils.renderIntoDocument(stub);
65
var node = ReactDOM.findDOMNode(stub);
@@ -67,7 +67,7 @@ describe('ReactDOMInput', function() {
67
expect(node.value).toBe('false');
68
});
69
70
- it('should update `defaultValue` for uncontrolled input', function() {
70
+ it('should update `defaultValue` for uncontrolled input', () => {
71
var container = document.createElement('div');
72
73
var node = ReactDOM.render(<input type="text" defaultValue="0" />, container);
@@ -80,7 +80,7 @@ describe('ReactDOMInput', function() {
80
expect(node.defaultValue).toBe('1');
81
});
82
83
- it('should update `defaultValue` for uncontrolled date/time input', function() {
83
+ it('should update `defaultValue` for uncontrolled date/time input', () => {
84
var container = document.createElement('div');
85
86
var node = ReactDOM.render(<input type="date" defaultValue="1980-01-01" />, container);
@@ -95,7 +95,7 @@ describe('ReactDOMInput', function() {
95
ReactDOM.render(<input type="date" />, container);
96
});
97
98
- it('should take `defaultValue` when changing to uncontrolled input', function() {
98
+ it('should take `defaultValue` when changing to uncontrolled input', () => {
99
var container = document.createElement('div');
100
101
var node = ReactDOM.render(<input type="text" value="0" readOnly="true" />, container);
@@ -107,7 +107,7 @@ describe('ReactDOMInput', function() {
107
expect(node.value).toBe('0');
108
});
109
110
- it('should render defaultValue for SSR', function() {
110
+ it('should render defaultValue for SSR', () => {
111
var markup = ReactDOMServer.renderToString(<input type="text" defaultValue="1" />);
112
var div = document.createElement('div');
113
div.innerHTML = markup;
@@ -115,7 +115,7 @@ describe('ReactDOMInput', function() {
115
expect(div.firstChild.getAttribute('defaultValue')).toBe(null);
116
});
117
118
- it('should render value for SSR', function() {
118
+ it('should render value for SSR', () => {
119
var element = <input type="text" value="1" onChange={function() {}} />;
120
var markup = ReactDOMServer.renderToString(element);
121
var div = document.createElement('div');
@@ -124,14 +124,14 @@ describe('ReactDOMInput', function() {
124
expect(div.firstChild.getAttribute('defaultValue')).toBe(null);
125
});
126
127
- it('should render name attribute if it is supplied', function() {
127
+ it('should render name attribute if it is supplied', () => {
128
var container = document.createElement('div');
129
var node = ReactDOM.render(<input type="text" name="name" />, container);
130
expect(node.name).toBe('name');
131
expect(container.firstChild.getAttribute('name')).toBe('name');
132
});
133
134
- it('should render name attribute if it is supplied for SSR', function() {
134
+ it('should render name attribute if it is supplied for SSR', () => {
135
var element = <input type="text" name="name" />;
136
var markup = ReactDOMServer.renderToString(element);
137
var div = document.createElement('div');
@@ -139,13 +139,13 @@ describe('ReactDOMInput', function() {
139
expect(div.firstChild.getAttribute('name')).toBe('name');
140
});
141
142
- it('should not render name attribute if it is not supplied', function() {
142
+ it('should not render name attribute if it is not supplied', () => {
143
var container = document.createElement('div');
144
ReactDOM.render(<input type="text" />, container);
145
expect(container.firstChild.getAttribute('name')).toBe(null);
146
});
147
148
- it('should not render name attribute if it is not supplied for SSR', function() {
148
+ it('should not render name attribute if it is not supplied for SSR', () => {
149
var element = <input type="text" />;
150
var markup = ReactDOMServer.renderToString(element);
151
var div = document.createElement('div');
@@ -153,7 +153,7 @@ describe('ReactDOMInput', function() {
153
expect(div.firstChild.getAttribute('name')).toBe(null);
154
});
155
156
- it('should display "foobar" for `defaultValue` of `objToString`', function() {
156
+ it('should display "foobar" for `defaultValue` of `objToString`', () => {
157
var objToString = {
158
toString: function() {
159
return 'foobar';
@@ -167,7 +167,7 @@ describe('ReactDOMInput', function() {
167
expect(node.value).toBe('foobar');
168
});
169
170
- it('should display `value` of number 0', function() {
170
+ it('should display `value` of number 0', () => {
171
var stub = <input type="text" value={0} />;
172
stub = ReactTestUtils.renderIntoDocument(stub);
173
var node = ReactDOM.findDOMNode(stub);
@@ -175,7 +175,7 @@ describe('ReactDOMInput', function() {
175
expect(node.value).toBe('0');
176
});
177
178
- it('should allow setting `value` to `true`', function() {
178
+ it('should allow setting `value` to `true`', () => {
179
var container = document.createElement('div');
180
var stub = <input type="text" value="yolo" onChange={emptyFunction} />;
181
var node = ReactDOM.render(stub, container);
@@ -189,7 +189,7 @@ describe('ReactDOMInput', function() {
189
expect(node.value).toEqual('true');
190
});
191
192
- it('should allow setting `value` to `false`', function() {
192
+ it('should allow setting `value` to `false`', () => {
193
var container = document.createElement('div');
194
var stub = <input type="text" value="yolo" onChange={emptyFunction} />;
195
var node = ReactDOM.render(stub, container);
@@ -203,7 +203,7 @@ describe('ReactDOMInput', function() {
203
expect(node.value).toEqual('false');
204
});
205
206
- it('should allow setting `value` to `objToString`', function() {
206
+ it('should allow setting `value` to `objToString`', () => {
207
var container = document.createElement('div');
208
var stub = <input type="text" value="foo" onChange={emptyFunction} />;
209
var node = ReactDOM.render(stub, container);
@@ -222,7 +222,7 @@ describe('ReactDOMInput', function() {
222
expect(node.value).toEqual('foobar');
223
});
224
225
- it('should not incur unnecessary DOM mutations', function() {
225
+ it('should not incur unnecessary DOM mutations', () => {
226
var container = document.createElement('div');
227
ReactDOM.render(<input value="a" />, container);
228
@@ -245,7 +245,7 @@ describe('ReactDOMInput', function() {
245
expect(nodeValueSetter.mock.calls.length).toBe(1);
246
});
247
248
- it('should properly control a value of number `0`', function() {
248
+ it('should properly control a value of number `0`', () => {
249
var stub = <input type="text" value={0} onChange={emptyFunction} />;
250
stub = ReactTestUtils.renderIntoDocument(stub);
251
var node = ReactDOM.findDOMNode(stub);
@@ -255,7 +255,7 @@ describe('ReactDOMInput', function() {
255
expect(node.value).toBe('0');
256
});
257
258
- it('should have the correct target value', function() {
258
+ it('should have the correct target value', () => {
259
var handled = false;
260
var handler = function(event) {
261
expect(event.target.nodeName).toBe('INPUT');
@@ -279,7 +279,7 @@ describe('ReactDOMInput', function() {
279
expect(handled).toBe(true);
280
});
281
282
- it('should not set a value for submit buttons unnecessarily', function() {
282
+ it('should not set a value for submit buttons unnecessarily', () => {
283
var stub = <input type="submit" />;
284
stub = ReactTestUtils.renderIntoDocument(stub);
285
var node = ReactDOM.findDOMNode(stub);
@@ -293,7 +293,7 @@ describe('ReactDOMInput', function() {
293
).toBe(true);
294
});
295
296
- it('should control radio buttons', function() {
296
+ it('should control radio buttons', () => {
297
class RadioGroup extends React.Component {
298
render() {
299
return (
@@ -351,7 +351,7 @@ describe('ReactDOMInput', function() {
351
expect(cNode.checked).toBe(true);
352
});
353
354
- it('should support ReactLink', function() {
354
+ it('should support ReactLink', () => {
355
var link = new ReactLink('yolo', jest.fn());
356
var instance = <input type="text" valueLink={link} />;
357
@@ -368,7 +368,7 @@ describe('ReactDOMInput', function() {
368
expect(link.requestChange.mock.calls[0][0]).toEqual('test');
369
});
370
371
- it('should warn with value and no onChange handler', function() {
371
+ it('should warn with value and no onChange handler', () => {
372
var link = new ReactLink('yolo', jest.fn());
373
ReactTestUtils.renderIntoDocument(<input type="text" valueLink={link} />);
374
expect(console.error.calls.count()).toBe(1);
@@ -384,7 +384,7 @@ describe('ReactDOMInput', function() {
384
expect(console.error.calls.count()).toBe(2);
385
});
386
387
- it('should warn with value and no onChange handler and readOnly specified', function() {
387
+ it('should warn with value and no onChange handler and readOnly specified', () => {
388
ReactTestUtils.renderIntoDocument(
389
<input type="text" value="zoink" readOnly={true} />
390
);
@@ -396,7 +396,7 @@ describe('ReactDOMInput', function() {
396
expect(console.error.calls.count()).toBe(1);
397
});
398
399
- it('should have a this value of undefined if bind is not used', function() {
399
+ it('should have a this value of undefined if bind is not used', () => {
400
var unboundInputOnChange = function() {
401
expect(this).toBe(undefined);
402
};
@@ -407,7 +407,7 @@ describe('ReactDOMInput', function() {
407
ReactTestUtils.Simulate.change(instance);
408
});
409
410
- it('should throw if both value and valueLink are provided', function() {
410
+ it('should throw if both value and valueLink are provided', () => {
411
var node = document.createElement('div');
412
var link = new ReactLink('yolo', jest.fn());
413
var instance = <input type="text" valueLink={link} />;
@@ -428,7 +428,7 @@ describe('ReactDOMInput', function() {
428
429
});
430
431
- it('should support checkedLink', function() {
431
+ it('should support checkedLink', () => {
432
var link = new ReactLink(true, jest.fn());
433
var instance = <input type="checkbox" checkedLink={link} />;
434
@@ -445,7 +445,7 @@ describe('ReactDOMInput', function() {
445
expect(link.requestChange.mock.calls[0][0]).toEqual(false);
446
});
447
448
- it('should warn with checked and no onChange handler', function() {
448
+ it('should warn with checked and no onChange handler', () => {
449
var node = document.createElement('div');
450
var link = new ReactLink(true, jest.fn());
451
ReactDOM.render(<input type="checkbox" checkedLink={link} />, node);
@@ -472,7 +472,7 @@ describe('ReactDOMInput', function() {
472
expect(console.error.calls.count()).toBe(2);
473
});
474
475
- it('should warn with checked and no onChange handler with readOnly specified', function() {
475
+ it('should warn with checked and no onChange handler with readOnly specified', () => {
476
ReactTestUtils.renderIntoDocument(
477
<input type="checkbox" checked="false" readOnly={true} />
478
);
@@ -484,7 +484,7 @@ describe('ReactDOMInput', function() {
484
expect(console.error.calls.count()).toBe(1);
485
});
486
487
- it('should throw if both checked and checkedLink are provided', function() {
487
+ it('should throw if both checked and checkedLink are provided', () => {
488
var node = document.createElement('div');
489
var link = new ReactLink(true, jest.fn());
490
var instance = <input type="checkbox" checkedLink={link} />;
@@ -506,14 +506,14 @@ describe('ReactDOMInput', function() {
506
507
});
508
509
- it('should update defaultValue to empty string', function() {
509
+ it('should update defaultValue to empty string', () => {
510
var container = document.createElement('div');
511
ReactDOM.render(<input type="text" defaultValue={'foo'} />, container);
512
ReactDOM.render(<input type="text" defaultValue={''} />, container);
513
expect(container.firstChild.defaultValue).toBe('');
514
});
515
516
- it('should throw if both checkedLink and valueLink are provided', function() {
516
+ it('should throw if both checkedLink and valueLink are provided', () => {
517
var node = document.createElement('div');
518
var link = new ReactLink(true, jest.fn());
519
var instance = <input type="checkbox" checkedLink={link} />;
@@ -528,7 +528,7 @@ describe('ReactDOMInput', function() {
528
expect(() => ReactDOM.render(instance, node)).toThrow();
529
});
530
531
- it('should warn if value is null', function() {
531
+ it('should warn if value is null', () => {
532
ReactTestUtils.renderIntoDocument(<input type="text" value={null} />);
533
expect(console.error.calls.argsFor(0)[0]).toContain(
534
'`value` prop on `input` should not be null. ' +
@@ -540,7 +540,7 @@ describe('ReactDOMInput', function() {
540
expect(console.error.calls.count()).toBe(1);
541
});
542
543
- it('should warn if checked and defaultChecked props are specified', function() {
543
+ it('should warn if checked and defaultChecked props are specified', () => {
544
ReactTestUtils.renderIntoDocument(
545
<input type="radio" checked={true} defaultChecked={true} readOnly={true} />
546
);
@@ -559,7 +559,7 @@ describe('ReactDOMInput', function() {
559
expect(console.error.calls.count()).toBe(1);
560
});
561
562
- it('should warn if value and defaultValue props are specified', function() {
562
+ it('should warn if value and defaultValue props are specified', () => {
563
ReactTestUtils.renderIntoDocument(
564
<input type="text" value="foo" defaultValue="bar" readOnly={true} />
565
);
@@ -578,7 +578,7 @@ describe('ReactDOMInput', function() {
578
expect(console.error.calls.count()).toBe(1);
579
});
580
581
- it('should warn if controlled input switches to uncontrolled (value is undefined)', function() {
581
+ it('should warn if controlled input switches to uncontrolled (value is undefined)', () => {
582
var stub = <input type="text" value="controlled" onChange={emptyFunction} />;
583
var container = document.createElement('div');
584
ReactDOM.render(stub, container);
@@ -592,7 +592,7 @@ describe('ReactDOMInput', function() {
592
);
593
});
594
595
- it('should warn if controlled input switches to uncontrolled (value is null)', function() {
595
+ it('should warn if controlled input switches to uncontrolled (value is null)', () => {
596
var stub = <input type="text" value="controlled" onChange={emptyFunction} />;
597
var container = document.createElement('div');
598
ReactDOM.render(stub, container);
@@ -606,7 +606,7 @@ describe('ReactDOMInput', function() {
606
);
607
});
608
609
- it('should warn if controlled input switches to uncontrolled with defaultValue', function() {
609
+ it('should warn if controlled input switches to uncontrolled with defaultValue', () => {
610
var stub = <input type="text" value="controlled" onChange={emptyFunction} />;
611
var container = document.createElement('div');
612
ReactDOM.render(stub, container);
@@ -620,7 +620,7 @@ describe('ReactDOMInput', function() {
620
);
621
});
622
623
- it('should warn if uncontrolled input (value is undefined) switches to controlled', function() {
623
+ it('should warn if uncontrolled input (value is undefined) switches to controlled', () => {
624
var stub = <input type="text" />;
625
var container = document.createElement('div');
626
ReactDOM.render(stub, container);
@@ -634,7 +634,7 @@ describe('ReactDOMInput', function() {
634
);
635
});
636
637
- it('should warn if uncontrolled input (value is null) switches to controlled', function() {
637
+ it('should warn if uncontrolled input (value is null) switches to controlled', () => {
638
var stub = <input type="text" value={null} />;
639
var container = document.createElement('div');
640
ReactDOM.render(stub, container);
@@ -648,7 +648,7 @@ describe('ReactDOMInput', function() {
648
);
649
});
650
651
- it('should warn if controlled checkbox switches to uncontrolled (checked is undefined)', function() {
651
+ it('should warn if controlled checkbox switches to uncontrolled (checked is undefined)', () => {
652
var stub = <input type="checkbox" checked={true} onChange={emptyFunction} />;
653
var container = document.createElement('div');
654
ReactDOM.render(stub, container);
@@ -662,7 +662,7 @@ describe('ReactDOMInput', function() {
662
);
663
});
664
665
- it('should warn if controlled checkbox switches to uncontrolled (checked is null)', function() {
665
+ it('should warn if controlled checkbox switches to uncontrolled (checked is null)', () => {
666
var stub = <input type="checkbox" checked={true} onChange={emptyFunction} />;
667
var container = document.createElement('div');
668
ReactDOM.render(stub, container);
@@ -676,7 +676,7 @@ describe('ReactDOMInput', function() {
676
);
677
});
678
679
- it('should warn if controlled checkbox switches to uncontrolled with defaultChecked', function() {
679
+ it('should warn if controlled checkbox switches to uncontrolled with defaultChecked', () => {
680
var stub = <input type="checkbox" checked={true} onChange={emptyFunction} />;
681
var container = document.createElement('div');
682
ReactDOM.render(stub, container);
@@ -690,7 +690,7 @@ describe('ReactDOMInput', function() {
690
);
691
});
692
693
- it('should warn if uncontrolled checkbox (checked is undefined) switches to controlled', function() {
693
+ it('should warn if uncontrolled checkbox (checked is undefined) switches to controlled', () => {
694
var stub = <input type="checkbox" />;
695
var container = document.createElement('div');
696
ReactDOM.render(stub, container);
@@ -704,7 +704,7 @@ describe('ReactDOMInput', function() {
704
);
705
});
706
707
- it('should warn if uncontrolled checkbox (checked is null) switches to controlled', function() {
707
+ it('should warn if uncontrolled checkbox (checked is null) switches to controlled', () => {
708
var stub = <input type="checkbox" checked={null} />;
709
var container = document.createElement('div');
710
ReactDOM.render(stub, container);
@@ -718,7 +718,7 @@ describe('ReactDOMInput', function() {
718
);
719
});
720
721
- it('should warn if controlled radio switches to uncontrolled (checked is undefined)', function() {
721
+ it('should warn if controlled radio switches to uncontrolled (checked is undefined)', () => {
722
var stub = <input type="radio" checked={true} onChange={emptyFunction} />;
723
var container = document.createElement('div');
724
ReactDOM.render(stub, container);
@@ -732,7 +732,7 @@ describe('ReactDOMInput', function() {
732
);
733
});
734
735
- it('should warn if controlled radio switches to uncontrolled (checked is null)', function() {
735
+ it('should warn if controlled radio switches to uncontrolled (checked is null)', () => {
736
var stub = <input type="radio" checked={true} onChange={emptyFunction} />;
737
var container = document.createElement('div');
738
ReactDOM.render(stub, container);
@@ -746,7 +746,7 @@ describe('ReactDOMInput', function() {
746
);
747
});
748
749
- it('should warn if controlled radio switches to uncontrolled with defaultChecked', function() {
749
+ it('should warn if controlled radio switches to uncontrolled with defaultChecked', () => {
750
var stub = <input type="radio" checked={true} onChange={emptyFunction} />;
751
var container = document.createElement('div');
752
ReactDOM.render(stub, container);
@@ -760,7 +760,7 @@ describe('ReactDOMInput', function() {
760
);
761
});
762
763
- it('should warn if uncontrolled radio (checked is undefined) switches to controlled', function() {
763
+ it('should warn if uncontrolled radio (checked is undefined) switches to controlled', () => {
764
var stub = <input type="radio" />;
765
var container = document.createElement('div');
766
ReactDOM.render(stub, container);
@@ -774,7 +774,7 @@ describe('ReactDOMInput', function() {
774
);
775
});
776
777
- it('should warn if uncontrolled radio (checked is null) switches to controlled', function() {
777
+ it('should warn if uncontrolled radio (checked is null) switches to controlled', () => {
778
var stub = <input type="radio" checked={null} />;
779
var container = document.createElement('div');
780
ReactDOM.render(stub, container);
@@ -788,7 +788,7 @@ describe('ReactDOMInput', function() {
788
);
789
});
790
791
- it('should not warn if radio value changes but never becomes controlled', function() {
791
+ it('should not warn if radio value changes but never becomes controlled', () => {
792
var container = document.createElement('div');
793
ReactDOM.render(<input type="radio" value="value" />, container);
794
ReactDOM.render(<input type="radio" />, container);
@@ -798,7 +798,7 @@ describe('ReactDOMInput', function() {
798
expect(console.error.calls.count()).toBe(0);
799
});
800
801
- it('should not warn if radio value changes but never becomes uncontrolled', function() {
801
+ it('should not warn if radio value changes but never becomes uncontrolled', () => {
802
var container = document.createElement('div');
803
ReactDOM.render(<input type="radio" checked={false} onChange={() => null} />, container);
804
ReactDOM.render(
@@ -812,7 +812,7 @@ describe('ReactDOMInput', function() {
812
expect(console.error.calls.count()).toBe(0);
813
});
814
815
- it('should warn if radio checked false changes to become uncontrolled', function() {
815
+ it('should warn if radio checked false changes to become uncontrolled', () => {
816
var container = document.createElement('div');
817
ReactDOM.render(<input type="radio" value="value" checked={false} onChange={() => null} />, container);
818
ReactDOM.render(<input type="radio" value="value" />, container);
@@ -824,7 +824,7 @@ describe('ReactDOMInput', function() {
824
);
825
});
826
827
- it('sets type, step, min, max before value always', function() {
827
+ it('sets type, step, min, max before value always', () => {
828
if (!ReactDOMFeatureFlags.useCreateElement) {
829
return;
830
}
@@ -860,14 +860,14 @@ describe('ReactDOMInput', function() {
860
]);
861
});
862
863
- it('sets value properly with type coming later in props', function() {
863
+ it('sets value properly with type coming later in props', () => {
864
var input = ReactTestUtils.renderIntoDocument(
865
<input value="hi" type="radio" />
866
);
867
expect(input.value).toBe('hi');
868
});
869
870
- it('does not raise a validation warning when it switches types', function() {
870
+ it('does not raise a validation warning when it switches types', () => {
871
var Input = React.createClass({
872
getInitialState() {
873
return { type: 'number', value: 1000 };
@@ -887,7 +887,7 @@ describe('ReactDOMInput', function() {
887
expect(node.value).toEqual('Test');
888
});
889
890
- it('resets value of date/time input to fix bugs in iOS Safari', function() {
890
+ it('resets value of date/time input to fix bugs in iOS Safari', () => {
891
// https://github.com/facebook/react/issues/7233
892
if (!ReactDOMFeatureFlags.useCreateElement) {
893
return;
src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js
+8
-8
@@ -12,18 +12,18 @@
12
'use strict';
13
14
15
-describe('ReactDOMOption', function() {
15
+describe('ReactDOMOption', () => {
16
var React;
17
var ReactDOM;
18
var ReactTestUtils;
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
React = require('React');
22
ReactDOM = require('ReactDOM');
23
ReactTestUtils = require('ReactTestUtils');
24
});
25
26
- it('should flatten children to a string', function() {
26
+ it('should flatten children to a string', () => {
27
var stub = <option>{1} {'foo'}</option>;
28
stub = ReactTestUtils.renderIntoDocument(stub);
29
var node = ReactDOM.findDOMNode(stub);
@@ -31,7 +31,7 @@ describe('ReactDOMOption', function() {
31
expect(node.innerHTML).toBe('1 foo');
32
});
33
34
- it('should ignore and warn invalid children types', function() {
34
+ it('should ignore and warn invalid children types', () => {
35
spyOn(console, 'error');
36
var stub = <option>{1} <div /> {2}</option>;
37
stub = ReactTestUtils.renderIntoDocument(stub);
@@ -43,7 +43,7 @@ describe('ReactDOMOption', function() {
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() {
46
+ it('should ignore null/undefined/false children without warning', () => {
47
var stub = <option>{1} {false}{true}{null}{undefined} {2}</option>;
48
spyOn(console, 'error');
49
stub = ReactTestUtils.renderIntoDocument(stub);
@@ -54,7 +54,7 @@ describe('ReactDOMOption', function() {
54
expect(node.innerHTML).toBe('1 2');
55
});
56
57
- it('should be able to use dangerouslySetInnerHTML on option', function() {
57
+ it('should be able to use dangerouslySetInnerHTML on option', () => {
58
var stub = <option dangerouslySetInnerHTML={{ __html: 'foobar' }} />;
59
stub = ReactTestUtils.renderIntoDocument(stub);
60
@@ -62,7 +62,7 @@ describe('ReactDOMOption', function() {
62
expect(node.innerHTML).toBe('foobar');
63
});
64
65
- it('should set attribute for empty value', function() {
65
+ it('should set attribute for empty value', () => {
66
var container = document.createElement('div');
67
var option = ReactDOM.render(<option value="" />, container);
68
expect(option.hasAttribute('value')).toBe(true);
@@ -73,7 +73,7 @@ describe('ReactDOMOption', function() {
73
expect(option.getAttribute('value')).toBe('lava');
74
});
75
76
- it('should allow ignoring `value` on option', function() {
76
+ it('should allow ignoring `value` on option', () => {
77
var a = 'a';
78
var stub =
79
<select value="giraffe" onChange={() => {}}>
src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js
+26
-26
@@ -12,7 +12,7 @@
12
'use strict';
13
14
15
-describe('ReactDOMSelect', function() {
15
+describe('ReactDOMSelect', () => {
16
var React;
17
var ReactDOM;
18
var ReactDOMServer;
@@ -21,7 +21,7 @@ describe('ReactDOMSelect', function() {
21
22
var noop = function() {};
23
24
- beforeEach(function() {
24
+ beforeEach(() => {
25
React = require('React');
26
ReactDOM = require('ReactDOM');
27
ReactDOMServer = require('ReactDOMServer');
@@ -29,7 +29,7 @@ describe('ReactDOMSelect', function() {
29
ReactTestUtils = require('ReactTestUtils');
30
});
31
32
- it('should allow setting `defaultValue`', function() {
32
+ it('should allow setting `defaultValue`', () => {
33
var stub =
34
<select defaultValue="giraffe">
35
<option value="monkey">A monkey!</option>
@@ -51,7 +51,7 @@ describe('ReactDOMSelect', function() {
51
expect(node.value).toEqual('giraffe');
52
});
53
54
- it('should not throw with `defaultValue` and without children', function() {
54
+ it('should not throw with `defaultValue` and without children', () => {
55
var stub = <select defaultValue="dummy"></select>;
56
57
expect(() => {
@@ -59,7 +59,7 @@ describe('ReactDOMSelect', function() {
59
}).not.toThrow();
60
});
61
62
- it('should not control when using `defaultValue`', function() {
62
+ it('should not control when using `defaultValue`', () => {
63
var el =
64
<select defaultValue="giraffe">
65
<option value="monkey">A monkey!</option>
@@ -78,7 +78,7 @@ describe('ReactDOMSelect', function() {
78
expect(node.value).toEqual('monkey');
79
});
80
81
- it('should allow setting `defaultValue` with multiple', function() {
81
+ it('should allow setting `defaultValue` with multiple', () => {
82
var stub =
83
<select multiple={true} defaultValue={['giraffe', 'gorilla']}>
84
<option value="monkey">A monkey!</option>
@@ -105,7 +105,7 @@ describe('ReactDOMSelect', function() {
105
expect(node.options[2].selected).toBe(true); // gorilla
106
});
107
108
- it('should allow setting `value`', function() {
108
+ it('should allow setting `value`', () => {
109
var stub =
110
<select value="giraffe" onChange={noop}>
111
<option value="monkey">A monkey!</option>
@@ -127,7 +127,7 @@ describe('ReactDOMSelect', function() {
127
expect(node.value).toEqual('gorilla');
128
});
129
130
- it('should not throw with `value` and without children', function() {
130
+ it('should not throw with `value` and without children', () => {
131
var stub = <select value="dummy" onChange={noop}></select>;
132
133
expect(() => {
@@ -135,7 +135,7 @@ describe('ReactDOMSelect', function() {
135
}).not.toThrow();
136
});
137
138
- it('should allow setting `value` with multiple', function() {
138
+ it('should allow setting `value` with multiple', () => {
139
var stub =
140
<select multiple={true} value={['giraffe', 'gorilla']} onChange={noop}>
141
<option value="monkey">A monkey!</option>
@@ -164,7 +164,7 @@ describe('ReactDOMSelect', function() {
164
expect(node.options[2].selected).toBe(false); // gorilla
165
});
166
167
- it('should not select other options automatically', function() {
167
+ it('should not select other options automatically', () => {
168
var stub =
169
<select multiple={true} value={['12']} onChange={noop}>
170
<option value="1">one</option>
@@ -179,7 +179,7 @@ describe('ReactDOMSelect', function() {
179
expect(node.options[2].selected).toBe(true); // twelve
180
});
181
182
- it('should reset child options selected when they are changed and `value` is set', function() {
182
+ it('should reset child options selected when they are changed and `value` is set', () => {
183
var stub = <select multiple={true} value={['a', 'b']} onChange={noop} />;
184
var container = document.createElement('div');
185
stub = ReactDOM.render(stub, container);
@@ -200,7 +200,7 @@ describe('ReactDOMSelect', function() {
200
expect(node.options[2].selected).toBe(false); // c
201
});
202
203
- it('should allow setting `value` with `objectToString`', function() {
203
+ it('should allow setting `value` with `objectToString`', () => {
204
var objectToString = {
205
animal: 'giraffe',
206
toString: function() {
@@ -238,7 +238,7 @@ describe('ReactDOMSelect', function() {
238
expect(node.options[2].selected).toBe(false); // gorilla
239
});
240
241
- it('should allow switching to multiple', function() {
241
+ it('should allow switching to multiple', () => {
242
var stub =
243
<select defaultValue="giraffe">
244
<option value="monkey">A monkey!</option>
@@ -267,7 +267,7 @@ describe('ReactDOMSelect', function() {
267
expect(node.options[2].selected).toBe(true); // gorilla
268
});
269
270
- it('should allow switching from multiple', function() {
270
+ it('should allow switching from multiple', () => {
271
var stub =
272
<select multiple={true} defaultValue={['giraffe', 'gorilla']}>
273
<option value="monkey">A monkey!</option>
@@ -296,7 +296,7 @@ describe('ReactDOMSelect', function() {
296
expect(node.options[2].selected).toBe(true); // gorilla
297
});
298
299
- it('should remember value when switching to uncontrolled', function() {
299
+ it('should remember value when switching to uncontrolled', () => {
300
var stub =
301
<select value={'giraffe'} onChange={noop}>
302
<option value="monkey">A monkey!</option>
@@ -319,7 +319,7 @@ describe('ReactDOMSelect', function() {
319
expect(node.options[2].selected).toBe(false); // gorilla
320
});
321
322
- it('should remember updated value when switching to uncontrolled', function() {
322
+ it('should remember updated value when switching to uncontrolled', () => {
323
var stub =
324
<select value={'giraffe'} onChange={noop}>
325
<option value="monkey">A monkey!</option>
@@ -347,7 +347,7 @@ describe('ReactDOMSelect', function() {
347
expect(node.options[2].selected).toBe(true); // gorilla
348
});
349
350
- it('should support ReactLink', function() {
350
+ it('should support ReactLink', () => {
351
var link = new ReactLink('giraffe', jest.fn());
352
var stub =
353
<select valueLink={link}>
@@ -381,7 +381,7 @@ describe('ReactDOMSelect', function() {
381
382
});
383
384
- it('should support server-side rendering', function() {
384
+ it('should support server-side rendering', () => {
385
var stub =
386
<select value="giraffe" onChange={noop}>
387
<option value="monkey">A monkey!</option>
@@ -394,7 +394,7 @@ describe('ReactDOMSelect', function() {
394
expect(markup).not.toContain('<option selected="" value="gorilla"');
395
});
396
397
- it('should support server-side rendering with defaultValue', function() {
397
+ it('should support server-side rendering with defaultValue', () => {
398
var stub =
399
<select defaultValue="giraffe">
400
<option value="monkey">A monkey!</option>
@@ -407,7 +407,7 @@ describe('ReactDOMSelect', function() {
407
expect(markup).not.toContain('<option selected="" value="gorilla"');
408
});
409
410
- it('should support server-side rendering with multiple', function() {
410
+ it('should support server-side rendering with multiple', () => {
411
var stub =
412
<select multiple={true} value={['giraffe', 'gorilla']} onChange={noop}>
413
<option value="monkey">A monkey!</option>
@@ -420,7 +420,7 @@ describe('ReactDOMSelect', function() {
420
expect(markup).not.toContain('<option selected="" value="monkey"');
421
});
422
423
- it('should not control defaultValue if readding options', function() {
423
+ it('should not control defaultValue if readding options', () => {
424
var container = document.createElement('div');
425
426
var select = ReactDOM.render(
@@ -462,7 +462,7 @@ describe('ReactDOMSelect', function() {
462
expect(node.options[2].selected).toBe(false); // gorilla
463
});
464
465
- it('should warn if value is null', function() {
465
+ it('should warn if value is null', () => {
466
spyOn(console, 'error');
467
468
ReactTestUtils.renderIntoDocument(<select value={null}><option value="test"/></select>);
@@ -476,7 +476,7 @@ describe('ReactDOMSelect', function() {
476
expect(console.error.calls.count()).toBe(1);
477
});
478
479
- it('should refresh state on change', function() {
479
+ it('should refresh state on change', () => {
480
var stub =
481
<select value="giraffe" onChange={noop}>
482
<option value="monkey">A monkey!</option>
@@ -491,7 +491,7 @@ describe('ReactDOMSelect', function() {
491
expect(node.value).toBe('giraffe');
492
});
493
494
- it('should warn if value and defaultValue props are specified', function() {
494
+ it('should warn if value and defaultValue props are specified', () => {
495
spyOn(console, 'error');
496
ReactTestUtils.renderIntoDocument(
497
<select value="giraffe" defaultValue="giraffe" readOnly={true}>
@@ -518,7 +518,7 @@ describe('ReactDOMSelect', function() {
518
expect(console.error.calls.count()).toBe(1);
519
});
520
521
- it('should be able to safely remove select onChange', function() {
521
+ it('should be able to safely remove select onChange', () => {
522
function changeView() {
523
ReactDOM.unmountComponentAtNode(container);
524
}
@@ -538,7 +538,7 @@ describe('ReactDOMSelect', function() {
538
);
539
});
540
541
- it('should select grandchild options nested inside an optgroup', function() {
541
+ it('should select grandchild options nested inside an optgroup', () => {
542
var stub =
543
<select value="b" onChange={noop}>
544
<optgroup label="group">
src/renderers/dom/client/wrappers/__tests__/ReactDOMTextarea-test.js
+31
-31
@@ -13,7 +13,7 @@
13
14
var emptyFunction = require('emptyFunction');
15
16
-describe('ReactDOMTextarea', function() {
16
+describe('ReactDOMTextarea', () => {
17
var React;
18
var ReactDOM;
19
var ReactDOMServer;
@@ -22,7 +22,7 @@ describe('ReactDOMTextarea', function() {
22
23
var renderTextarea;
24
25
- beforeEach(function() {
25
+ beforeEach(() => {
26
React = require('React');
27
ReactDOM = require('ReactDOM');
28
ReactDOMServer = require('ReactDOMServer');
@@ -42,7 +42,7 @@ describe('ReactDOMTextarea', function() {
42
};
43
});
44
45
- it('should allow setting `defaultValue`', function() {
45
+ it('should allow setting `defaultValue`', () => {
46
var container = document.createElement('div');
47
var node = renderTextarea(<textarea defaultValue="giraffe" />, container);
48
@@ -58,21 +58,21 @@ describe('ReactDOMTextarea', function() {
58
expect(node.value).toEqual('cat');
59
});
60
61
- it('should display `defaultValue` of number 0', function() {
61
+ it('should display `defaultValue` of number 0', () => {
62
var stub = <textarea defaultValue={0} />;
63
var node = renderTextarea(stub);
64
65
expect(node.value).toBe('0');
66
});
67
68
- it('should display "false" for `defaultValue` of `false`', function() {
68
+ it('should display "false" for `defaultValue` of `false`', () => {
69
var stub = <textarea defaultValue={false} />;
70
var node = renderTextarea(stub);
71
72
expect(node.value).toBe('false');
73
});
74
75
- it('should display "foobar" for `defaultValue` of `objToString`', function() {
75
+ it('should display "foobar" for `defaultValue` of `objToString`', () => {
76
var objToString = {
77
toString: function() {
78
return 'foobar';
@@ -85,7 +85,7 @@ describe('ReactDOMTextarea', function() {
85
expect(node.value).toBe('foobar');
86
});
87
88
- it('should set defaultValue', function() {
88
+ it('should set defaultValue', () => {
89
var container = document.createElement('div');
90
ReactDOM.render(<textarea defaultValue="foo" />, container);
91
ReactDOM.render(<textarea defaultValue="bar" />, container);
@@ -93,28 +93,28 @@ describe('ReactDOMTextarea', function() {
93
expect(container.firstChild.defaultValue).toBe('noise');
94
});
95
96
- it('should not render value as an attribute', function() {
96
+ it('should not render value as an attribute', () => {
97
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
98
var node = renderTextarea(stub);
99
100
expect(node.getAttribute('value')).toBe(null);
101
});
102
103
- it('should display `value` of number 0', function() {
103
+ it('should display `value` of number 0', () => {
104
var stub = <textarea value={0} />;
105
var node = renderTextarea(stub);
106
107
expect(node.value).toBe('0');
108
});
109
110
- it('should update defaultValue to empty string', function() {
110
+ it('should update defaultValue to empty string', () => {
111
var container = document.createElement('div');
112
ReactDOM.render(<textarea defaultValue={'foo'} />, container);
113
ReactDOM.render(<textarea defaultValue={''} />, container);
114
expect(container.firstChild.defaultValue).toBe('');
115
});
116
117
- it('should allow setting `value` to `giraffe`', function() {
117
+ it('should allow setting `value` to `giraffe`', () => {
118
var container = document.createElement('div');
119
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
120
var node = renderTextarea(stub, container);
@@ -128,7 +128,7 @@ describe('ReactDOMTextarea', function() {
128
expect(node.value).toEqual('gorilla');
129
});
130
131
- it('should render defaultValue for SSR', function() {
131
+ it('should render defaultValue for SSR', () => {
132
var markup = ReactDOMServer.renderToString(<textarea defaultValue="1" />);
133
var div = document.createElement('div');
134
div.innerHTML = markup;
@@ -136,7 +136,7 @@ describe('ReactDOMTextarea', function() {
136
expect(div.firstChild.getAttribute('defaultValue')).toBe(null);
137
});
138
139
- it('should render value for SSR', function() {
139
+ it('should render value for SSR', () => {
140
var element = <textarea value="1" onChange={function() {}} />;
141
var markup = ReactDOMServer.renderToString(element);
142
var div = document.createElement('div');
@@ -145,7 +145,7 @@ describe('ReactDOMTextarea', function() {
145
expect(div.firstChild.getAttribute('defaultValue')).toBe(null);
146
});
147
148
- it('should allow setting `value` to `true`', function() {
148
+ it('should allow setting `value` to `true`', () => {
149
var container = document.createElement('div');
150
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
151
var node = renderTextarea(stub, container);
@@ -159,7 +159,7 @@ describe('ReactDOMTextarea', function() {
159
expect(node.value).toEqual('true');
160
});
161
162
- it('should allow setting `value` to `false`', function() {
162
+ it('should allow setting `value` to `false`', () => {
163
var container = document.createElement('div');
164
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
165
var node = renderTextarea(stub, container);
@@ -173,7 +173,7 @@ describe('ReactDOMTextarea', function() {
173
expect(node.value).toEqual('false');
174
});
175
176
- it('should allow setting `value` to `objToString`', function() {
176
+ it('should allow setting `value` to `objToString`', () => {
177
var container = document.createElement('div');
178
var stub = <textarea value="giraffe" onChange={emptyFunction} />;
179
var node = renderTextarea(stub, container);
@@ -192,7 +192,7 @@ describe('ReactDOMTextarea', function() {
192
expect(node.value).toEqual('foo');
193
});
194
195
- it('should take updates to `defaultValue` for uncontrolled textarea', function() {
195
+ it('should take updates to `defaultValue` for uncontrolled textarea', () => {
196
var container = document.createElement('div');
197
198
var node = ReactDOM.render(<textarea defaultValue="0" />, container);
@@ -204,7 +204,7 @@ describe('ReactDOMTextarea', function() {
204
expect(node.value).toBe('0');
205
});
206
207
- it('should take updates to children in lieu of `defaultValue` for uncontrolled textarea', function() {
207
+ it('should take updates to children in lieu of `defaultValue` for uncontrolled textarea', () => {
208
var container = document.createElement('div');
209
210
var node = ReactDOM.render(<textarea defaultValue="0" />, container);
@@ -218,7 +218,7 @@ describe('ReactDOMTextarea', function() {
218
expect(node.value).toBe('0');
219
});
220
221
- it('should not incur unnecessary DOM mutations', function() {
221
+ it('should not incur unnecessary DOM mutations', () => {
222
var container = document.createElement('div');
223
ReactDOM.render(<textarea value="a" onChange={emptyFunction} />, container);
224
@@ -241,7 +241,7 @@ describe('ReactDOMTextarea', function() {
241
expect(nodeValueSetter.mock.calls.length).toBe(1);
242
});
243
244
- it('should properly control a value of number `0`', function() {
244
+ it('should properly control a value of number `0`', () => {
245
var stub = <textarea value={0} onChange={emptyFunction} />;
246
var node = renderTextarea(stub);
247
@@ -250,7 +250,7 @@ describe('ReactDOMTextarea', function() {
250
expect(node.value).toBe('0');
251
});
252
253
- it('should treat children like `defaultValue`', function() {
253
+ it('should treat children like `defaultValue`', () => {
254
spyOn(console, 'error');
255
256
var container = document.createElement('div');
@@ -265,7 +265,7 @@ describe('ReactDOMTextarea', function() {
265
expect(node.value).toEqual('giraffe');
266
});
267
268
- it('should keep value when switching to uncontrolled element if not changed', function() {
268
+ it('should keep value when switching to uncontrolled element if not changed', () => {
269
var container = document.createElement('div');
270
271
var node = renderTextarea(<textarea value="kitten" onChange={emptyFunction} />, container);
@@ -277,7 +277,7 @@ describe('ReactDOMTextarea', function() {
277
expect(node.value).toEqual('kitten');
278
});
279
280
- it('should keep value when switching to uncontrolled element if changed', function() {
280
+ it('should keep value when switching to uncontrolled element if changed', () => {
281
var container = document.createElement('div');
282
283
var node = renderTextarea(<textarea value="kitten" onChange={emptyFunction} />, container);
@@ -293,21 +293,21 @@ describe('ReactDOMTextarea', function() {
293
expect(node.value).toEqual('puppies');
294
});
295
296
- it('should allow numbers as children', function() {
296
+ it('should allow numbers as children', () => {
297
spyOn(console, 'error');
298
var node = renderTextarea(<textarea>{17}</textarea>);
299
expect(console.error.calls.count()).toBe(1);
300
expect(node.value).toBe('17');
301
});
302
303
- it('should allow booleans as children', function() {
303
+ it('should allow booleans as children', () => {
304
spyOn(console, 'error');
305
var node = renderTextarea(<textarea>{false}</textarea>);
306
expect(console.error.calls.count()).toBe(1);
307
expect(node.value).toBe('false');
308
});
309
310
- it('should allow objects as children', function() {
310
+ it('should allow objects as children', () => {
311
spyOn(console, 'error');
312
var obj = {
313
toString: function() {
@@ -319,7 +319,7 @@ describe('ReactDOMTextarea', function() {
319
expect(node.value).toBe('sharkswithlasers');
320
});
321
322
- it('should throw with multiple or invalid children', function() {
322
+ it('should throw with multiple or invalid children', () => {
323
spyOn(console, 'error');
324
325
expect(function() {
@@ -340,7 +340,7 @@ describe('ReactDOMTextarea', function() {
340
expect(console.error.calls.count()).toBe(2);
341
});
342
343
- it('should support ReactLink', function() {
343
+ it('should support ReactLink', () => {
344
var link = new ReactLink('yolo', jest.fn());
345
var instance = <textarea valueLink={link} />;
346
@@ -363,13 +363,13 @@ describe('ReactDOMTextarea', function() {
363
expect(link.requestChange.mock.calls[0][0]).toEqual('test');
364
});
365
366
- it('should unmount', function() {
366
+ it('should unmount', () => {
367
var container = document.createElement('div');
368
renderTextarea(<textarea />, container);
369
ReactDOM.unmountComponentAtNode(container);
370
});
371
372
- it('should warn if value is null', function() {
372
+ it('should warn if value is null', () => {
373
spyOn(console, 'error');
374
375
ReactTestUtils.renderIntoDocument(<textarea value={null} />);
@@ -383,7 +383,7 @@ describe('ReactDOMTextarea', function() {
383
expect(console.error.calls.count()).toBe(1);
384
});
385
386
- it('should warn if value and defaultValue are specified', function() {
386
+ it('should warn if value and defaultValue are specified', () => {
387
spyOn(console, 'error');
388
ReactTestUtils.renderIntoDocument(
389
<textarea value="foo" defaultValue="bar" readOnly={true} />
src/renderers/dom/server/__tests__/ReactServerRendering-test.js
+25
-25
@@ -22,8 +22,8 @@ var ReactServerRendering;
22
var ID_ATTRIBUTE_NAME;
23
var ROOT_ATTRIBUTE_NAME;
24
25
-describe('ReactServerRendering', function() {
26
- beforeEach(function() {
25
+describe('ReactServerRendering', () => {
26
+ beforeEach(() => {
27
jest.resetModuleRegistry();
28
React = require('React');
29
ReactDOM = require('ReactDOM');
@@ -40,8 +40,8 @@ describe('ReactServerRendering', function() {
40
ROOT_ATTRIBUTE_NAME = DOMProperty.ROOT_ATTRIBUTE_NAME;
41
});
42
43
- describe('renderToString', function() {
44
- it('should generate simple markup', function() {
43
+ describe('renderToString', () => {
44
+ it('should generate simple markup', () => {
45
var response = ReactServerRendering.renderToString(
46
<span>hello world</span>
47
);
@@ -52,7 +52,7 @@ describe('ReactServerRendering', function() {
52
));
53
});
54
55
- it('should generate simple markup for self-closing tags', function() {
55
+ it('should generate simple markup for self-closing tags', () => {
56
var response = ReactServerRendering.renderToString(
57
<img />
58
);
@@ -63,7 +63,7 @@ describe('ReactServerRendering', function() {
63
));
64
});
65
66
- it('should generate simple markup for attribute with `>` symbol', function() {
66
+ it('should generate simple markup for attribute with `>` symbol', () => {
67
var response = ReactServerRendering.renderToString(
68
<img data-attr=">" />
69
);
@@ -74,7 +74,7 @@ describe('ReactServerRendering', function() {
74
));
75
});
76
77
- it('should generate comment markup for component returns null', function() {
77
+ it('should generate comment markup for component returns null', () => {
78
class NullComponent extends React.Component {
79
render() {
80
return null;
@@ -85,7 +85,7 @@ describe('ReactServerRendering', function() {
85
expect(response).toBe('<!-- react-empty: 1 -->');
86
});
87
88
- it('should not register event listeners', function() {
88
+ it('should not register event listeners', () => {
89
var EventPluginHub = require('EventPluginHub');
90
var cb = jest.fn();
91
@@ -95,7 +95,7 @@ describe('ReactServerRendering', function() {
95
expect(EventPluginHub.__getListenerBank()).toEqual({});
96
});
97
98
- it('should render composite components', function() {
98
+ it('should render composite components', () => {
99
class Parent extends React.Component {
100
render() {
101
return <div><Child name="child" /></div>;
@@ -123,7 +123,7 @@ describe('ReactServerRendering', function() {
123
));
124
});
125
126
- it('should only execute certain lifecycle methods', function() {
126
+ it('should only execute certain lifecycle methods', () => {
127
function runTest() {
128
var lifecycle = [];
129
@@ -192,7 +192,7 @@ describe('ReactServerRendering', function() {
192
runTest();
193
});
194
195
- it('should have the correct mounting behavior', function() {
195
+ it('should have the correct mounting behavior', () => {
196
// This test is testing client-side behavior.
197
ExecutionEnvironment.canUseDOM = true;
198
@@ -275,7 +275,7 @@ describe('ReactServerRendering', function() {
275
expect(numClicks).toEqual(2);
276
});
277
278
- it('should throw with silly args', function() {
278
+ it('should throw with silly args', () => {
279
expect(
280
ReactServerRendering.renderToString.bind(
281
ReactServerRendering,
@@ -287,8 +287,8 @@ describe('ReactServerRendering', function() {
287
});
288
});
289
290
- describe('renderToStaticMarkup', function() {
291
- it('should not put checksum and React ID on components', function() {
290
+ describe('renderToStaticMarkup', () => {
291
+ it('should not put checksum and React ID on components', () => {
292
class NestedComponent extends React.Component {
293
render() {
294
return <div>inner text</div>;
@@ -308,7 +308,7 @@ describe('ReactServerRendering', function() {
308
expect(response).toBe('<span><div>inner text</div></span>');
309
});
310
311
- it('should not put checksum and React ID on text components', function() {
311
+ it('should not put checksum and React ID on text components', () => {
312
class TestComponent extends React.Component {
313
render() {
314
return <span>{'hello'} {'world'}</span>;
@@ -322,7 +322,7 @@ describe('ReactServerRendering', function() {
322
expect(response).toBe('<span>hello world</span>');
323
});
324
325
- it('should not register event listeners', function() {
325
+ it('should not register event listeners', () => {
326
var EventPluginHub = require('EventPluginHub');
327
var cb = jest.fn();
328
@@ -332,7 +332,7 @@ describe('ReactServerRendering', function() {
332
expect(EventPluginHub.__getListenerBank()).toEqual({});
333
});
334
335
- it('should only execute certain lifecycle methods', function() {
335
+ it('should only execute certain lifecycle methods', () => {
336
function runTest() {
337
var lifecycle = [];
338
@@ -394,7 +394,7 @@ describe('ReactServerRendering', function() {
394
runTest();
395
});
396
397
- it('should throw with silly args', function() {
397
+ it('should throw with silly args', () => {
398
expect(
399
ReactServerRendering.renderToStaticMarkup.bind(
400
ReactServerRendering,
@@ -405,7 +405,7 @@ describe('ReactServerRendering', function() {
405
);
406
});
407
408
- it('allows setState in componentWillMount without using DOM', function() {
408
+ it('allows setState in componentWillMount without using DOM', () => {
409
class Component extends React.Component {
410
componentWillMount() {
411
this.setState({text: 'hello, world'});
@@ -426,7 +426,7 @@ describe('ReactServerRendering', function() {
426
expect(markup.indexOf('hello, world') >= 0).toBe(true);
427
});
428
429
- it('renders components with different batching strategies', function() {
429
+ it('renders components with different batching strategies', () => {
430
class StaticComponent extends React.Component {
431
render() {
432
const staticContent = ReactServerRendering.renderToStaticMarkup(
@@ -460,7 +460,7 @@ describe('ReactServerRendering', function() {
460
});
461
});
462
463
- it('warns with a no-op when an async setState is triggered', function() {
463
+ it('warns with a no-op when an async setState is triggered', () => {
464
class Foo extends React.Component {
465
componentWillMount() {
466
this.setState({text: 'hello'});
@@ -486,7 +486,7 @@ describe('ReactServerRendering', function() {
486
expect(markup).toBe('<div>hello</div>');
487
});
488
489
- it('warns with a no-op when an async replaceState is triggered', function() {
489
+ it('warns with a no-op when an async replaceState is triggered', () => {
490
var Bar = React.createClass({
491
componentWillMount: function() {
492
this.replaceState({text: 'hello'});
@@ -512,7 +512,7 @@ describe('ReactServerRendering', function() {
512
expect(markup).toBe('<div>hello</div>');
513
});
514
515
- it('warns with a no-op when an async forceUpdate is triggered', function() {
515
+ it('warns with a no-op when an async forceUpdate is triggered', () => {
516
class Baz extends React.Component {
517
componentWillMount() {
518
this.forceUpdate();
@@ -539,7 +539,7 @@ describe('ReactServerRendering', function() {
539
expect(markup).toBe('<div></div>');
540
});
541
542
- it('warns when children are mutated before render', function() {
542
+ it('warns when children are mutated before render', () => {
543
function normalizeCodeLocInfo(str) {
544
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
545
}
@@ -555,7 +555,7 @@ describe('ReactServerRendering', function() {
555
);
556
});
557
558
- it('should warn when children are mutated', function() {
558
+ it('should warn when children are mutated', () => {
559
function normalizeCodeLocInfo(str) {
560
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
561
}
src/renderers/dom/shared/__tests__/CSSProperty-test.js
+3
-3
@@ -11,15 +11,15 @@
11
12
'use strict';
13
14
-describe('CSSProperty', function() {
14
+describe('CSSProperty', () => {
15
var CSSProperty;
16
17
- beforeEach(function() {
17
+ beforeEach(() => {
18
jest.resetModuleRegistry();
19
CSSProperty = require('CSSProperty');
20
});
21
22
- it('should generate browser prefixes for its `isUnitlessNumber`', function() {
22
+ it('should generate browser prefixes for its `isUnitlessNumber`', () => {
23
expect(CSSProperty.isUnitlessNumber.lineClamp).toBeTruthy();
24
expect(CSSProperty.isUnitlessNumber.WebkitLineClamp).toBeTruthy();
25
expect(CSSProperty.isUnitlessNumber.msFlexGrow).toBeTruthy();
src/renderers/dom/shared/__tests__/CSSPropertyOperations-test.js
+17
-17
@@ -15,43 +15,43 @@ var React = require('React');
15
var ReactDOM = require('ReactDOM');
16
var ReactDOMServer = require('ReactDOMServer');
17
18
-describe('CSSPropertyOperations', function() {
18
+describe('CSSPropertyOperations', () => {
19
var CSSPropertyOperations;
20
21
- beforeEach(function() {
21
+ beforeEach(() => {
22
jest.resetModuleRegistry();
23
CSSPropertyOperations = require('CSSPropertyOperations');
24
});
25
26
- it('should create markup for simple styles', function() {
26
+ it('should create markup for simple styles', () => {
27
expect(CSSPropertyOperations.createMarkupForStyles({
28
backgroundColor: '#3b5998',
29
display: 'none',
30
})).toBe('background-color:#3b5998;display:none;');
31
});
32
33
- it('should ignore undefined styles', function() {
33
+ it('should ignore undefined styles', () => {
34
expect(CSSPropertyOperations.createMarkupForStyles({
35
backgroundColor: undefined,
36
display: 'none',
37
})).toBe('display:none;');
38
});
39
40
- it('should ignore null styles', function() {
40
+ it('should ignore null styles', () => {
41
expect(CSSPropertyOperations.createMarkupForStyles({
42
backgroundColor: null,
43
display: 'none',
44
})).toBe('display:none;');
45
});
46
47
- it('should return null for no styles', function() {
47
+ it('should return null for no styles', () => {
48
expect(CSSPropertyOperations.createMarkupForStyles({
49
backgroundColor: null,
50
display: null,
51
})).toBe(null);
52
});
53
54
- it('should automatically append `px` to relevant styles', function() {
54
+ it('should automatically append `px` to relevant styles', () => {
55
expect(CSSPropertyOperations.createMarkupForStyles({
56
left: 0,
57
margin: 16,
@@ -60,7 +60,7 @@ describe('CSSPropertyOperations', function() {
60
})).toBe('left:0;margin:16px;opacity:0.5;padding:4px;');
61
});
62
63
- it('should trim values', function() {
63
+ it('should trim values', () => {
64
expect(CSSPropertyOperations.createMarkupForStyles({
65
left: '16 ',
66
opacity: 0.5,
@@ -68,7 +68,7 @@ describe('CSSPropertyOperations', function() {
68
})).toBe('left:16;opacity:0.5;right:4;');
69
});
70
71
- it('should not append `px` to styles that might need a number', function() {
71
+ it('should not append `px` to styles that might need a number', () => {
72
var CSSProperty = require('CSSProperty');
73
var unitlessProperties = Object.keys(CSSProperty.isUnitlessNumber);
74
unitlessProperties.forEach(function(property) {
@@ -79,14 +79,14 @@ describe('CSSPropertyOperations', function() {
79
});
80
});
81
82
- it('should create vendor-prefixed markup correctly', function() {
82
+ it('should create vendor-prefixed markup correctly', () => {
83
expect(CSSPropertyOperations.createMarkupForStyles({
84
msTransition: 'none',
85
MozTransition: 'none',
86
})).toBe('-ms-transition:none;-moz-transition:none;');
87
});
88
89
- it('should set style attribute when styles exist', function() {
89
+ it('should set style attribute when styles exist', () => {
90
var styles = {
91
backgroundColor: '#000',
92
display: 'none',
@@ -97,7 +97,7 @@ describe('CSSPropertyOperations', function() {
97
expect(/style=".*"/.test(root.innerHTML)).toBe(true);
98
});
99
100
- it('should not set style attribute when no styles exist', function() {
100
+ it('should not set style attribute when no styles exist', () => {
101
var styles = {
102
backgroundColor: null,
103
display: null,
@@ -107,7 +107,7 @@ describe('CSSPropertyOperations', function() {
107
expect(/style=/.test(html)).toBe(false);
108
});
109
110
- it('should warn when using hyphenated style names', function() {
110
+ it('should warn when using hyphenated style names', () => {
111
class Comp extends React.Component {
112
static displayName = 'Comp';
113
@@ -126,7 +126,7 @@ describe('CSSPropertyOperations', function() {
126
);
127
});
128
129
- it('should warn when updating hyphenated style names', function() {
129
+ it('should warn when updating hyphenated style names', () => {
130
class Comp extends React.Component {
131
static displayName = 'Comp';
132
@@ -155,7 +155,7 @@ describe('CSSPropertyOperations', function() {
155
);
156
});
157
158
- it('warns when miscapitalizing vendored style names', function() {
158
+ it('warns when miscapitalizing vendored style names', () => {
159
class Comp extends React.Component {
160
static displayName = 'Comp';
161
@@ -183,7 +183,7 @@ describe('CSSPropertyOperations', function() {
183
);
184
});
185
186
- it('should warn about style having a trailing semicolon', function() {
186
+ it('should warn about style having a trailing semicolon', () => {
187
class Comp extends React.Component {
188
static displayName = 'Comp';
189
@@ -211,7 +211,7 @@ describe('CSSPropertyOperations', function() {
211
);
212
});
213
214
- it('should warn about style containing a NaN value', function() {
214
+ it('should warn about style containing a NaN value', () => {
215
class Comp extends React.Component {
216
static displayName = 'Comp';
217
src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js
+32
-32
@@ -11,12 +11,12 @@
11
12
'use strict';
13
14
-describe('DOMPropertyOperations', function() {
14
+describe('DOMPropertyOperations', () => {
15
var DOMPropertyOperations;
16
var DOMProperty;
17
var ReactDOMComponentTree;
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
jest.resetModuleRegistry();
21
var ReactDefaultInjection = require('ReactDefaultInjection');
22
ReactDefaultInjection.inject();
@@ -26,9 +26,9 @@ describe('DOMPropertyOperations', function() {
26
ReactDOMComponentTree = require('ReactDOMComponentTree');
27
});
28
29
- describe('createMarkupForProperty', function() {
29
+ describe('createMarkupForProperty', () => {
30
31
- it('should create markup for simple properties', function() {
31
+ it('should create markup for simple properties', () => {
32
expect(DOMPropertyOperations.createMarkupForProperty(
33
'name',
34
'simple'
@@ -45,14 +45,14 @@ describe('DOMPropertyOperations', function() {
45
)).toBe('');
46
});
47
48
- it('should work with the id attribute', function() {
48
+ it('should work with the id attribute', () => {
49
expect(DOMPropertyOperations.createMarkupForProperty(
50
'id',
51
'simple'
52
)).toBe('id="simple"');
53
});
54
55
- it('should create markup for boolean properties', function() {
55
+ it('should create markup for boolean properties', () => {
56
expect(DOMPropertyOperations.createMarkupForProperty(
57
'checked',
58
'simple'
@@ -74,7 +74,7 @@ describe('DOMPropertyOperations', function() {
74
)).toBe('scoped=""');
75
});
76
77
- it('should create markup for booleanish properties', function() {
77
+ it('should create markup for booleanish properties', () => {
78
expect(DOMPropertyOperations.createMarkupForProperty(
79
'download',
80
'simple'
@@ -116,7 +116,7 @@ describe('DOMPropertyOperations', function() {
116
)).toBe('download="0"');
117
});
118
119
- it('should create markup for custom attributes', function() {
119
+ it('should create markup for custom attributes', () => {
120
expect(DOMPropertyOperations.createMarkupForProperty(
121
'aria-label',
122
'simple'
@@ -133,7 +133,7 @@ describe('DOMPropertyOperations', function() {
133
)).toBe('');
134
});
135
136
- it('should create markup for numeric properties', function() {
136
+ it('should create markup for numeric properties', () => {
137
expect(DOMPropertyOperations.createMarkupForProperty(
138
'start',
139
5
@@ -157,9 +157,9 @@ describe('DOMPropertyOperations', function() {
157
158
});
159
160
- describe('createMarkupForProperty', function() {
160
+ describe('createMarkupForProperty', () => {
161
162
- it('should allow custom properties on web components', function() {
162
+ it('should allow custom properties on web components', () => {
163
expect(DOMPropertyOperations.createMarkupForCustomAttribute(
164
'awesomeness',
165
5
@@ -172,28 +172,28 @@ describe('DOMPropertyOperations', function() {
172
});
173
});
174
175
- describe('setValueForProperty', function() {
175
+ describe('setValueForProperty', () => {
176
var stubNode;
177
var stubInstance;
178
179
- beforeEach(function() {
179
+ beforeEach(() => {
180
stubNode = document.createElement('div');
181
stubInstance = {_debugID: 1};
182
ReactDOMComponentTree.precacheNode(stubInstance, stubNode);
183
});
184
185
- it('should set values as properties by default', function() {
185
+ it('should set values as properties by default', () => {
186
DOMPropertyOperations.setValueForProperty(stubNode, 'title', 'Tip!');
187
expect(stubNode.title).toBe('Tip!');
188
});
189
190
- it('should set values as attributes if necessary', function() {
190
+ it('should set values as attributes if necessary', () => {
191
DOMPropertyOperations.setValueForProperty(stubNode, 'role', '#');
192
expect(stubNode.getAttribute('role')).toBe('#');
193
expect(stubNode.role).toBeUndefined();
194
});
195
196
- it('should set values as namespace attributes if necessary', function() {
196
+ it('should set values as namespace attributes if necessary', () => {
197
spyOn(stubNode, 'setAttributeNS');
198
DOMPropertyOperations.setValueForProperty(
199
stubNode,
@@ -205,7 +205,7 @@ describe('DOMPropertyOperations', function() {
205
.toEqual(['http://www.w3.org/1999/xlink', 'xlink:href', 'about:blank']);
206
});
207
208
- it('should set values as boolean properties', function() {
208
+ it('should set values as boolean properties', () => {
209
DOMPropertyOperations.setValueForProperty(stubNode, 'disabled', 'disabled');
210
expect(stubNode.getAttribute('disabled')).toBe('');
211
DOMPropertyOperations.setValueForProperty(stubNode, 'disabled', true);
@@ -214,7 +214,7 @@ describe('DOMPropertyOperations', function() {
214
expect(stubNode.getAttribute('disabled')).toBe(null);
215
});
216
217
- it('should convert attribute values to string first', function() {
217
+ it('should convert attribute values to string first', () => {
218
// Browsers default to this behavior, but some test environments do not.
219
// This ensures that we have consistent behavior.
220
var obj = {
@@ -226,7 +226,7 @@ describe('DOMPropertyOperations', function() {
226
expect(stubNode.getAttribute('role')).toBe('<html>');
227
});
228
229
- it('should not remove empty attributes for special properties', function() {
229
+ it('should not remove empty attributes for special properties', () => {
230
stubNode = document.createElement('input');
231
ReactDOMComponentTree.precacheNode(stubInstance, stubNode);
232
@@ -236,7 +236,7 @@ describe('DOMPropertyOperations', function() {
236
expect(stubNode.value).toBe('');
237
});
238
239
- it('should remove for falsey boolean properties', function() {
239
+ it('should remove for falsey boolean properties', () => {
240
DOMPropertyOperations.setValueForProperty(
241
stubNode,
242
'allowFullScreen',
@@ -245,7 +245,7 @@ describe('DOMPropertyOperations', function() {
245
expect(stubNode.hasAttribute('allowFullScreen')).toBe(false);
246
});
247
248
- it('should remove when setting custom attr to null', function() {
248
+ it('should remove when setting custom attr to null', () => {
249
DOMPropertyOperations.setValueForProperty(
250
stubNode,
251
'data-foo',
@@ -260,7 +260,7 @@ describe('DOMPropertyOperations', function() {
260
expect(stubNode.hasAttribute('data-foo')).toBe(false);
261
});
262
263
- it('should use mutation method where applicable', function() {
263
+ it('should use mutation method where applicable', () => {
264
var foobarSetter = jest.fn();
265
// inject foobar DOM property
266
DOMProperty.injection.injectDOMPropertyConfig({
@@ -281,7 +281,7 @@ describe('DOMPropertyOperations', function() {
281
expect(foobarSetter.mock.calls[0][1]).toBe('cows say moo');
282
});
283
284
- it('should set className to empty string instead of null', function() {
284
+ it('should set className to empty string instead of null', () => {
285
DOMPropertyOperations.setValueForProperty(
286
stubNode,
287
'className',
@@ -300,7 +300,7 @@ describe('DOMPropertyOperations', function() {
300
expect(stubNode.getAttribute('class')).toBe(null);
301
});
302
303
- it('should remove property properly for boolean properties', function() {
303
+ it('should remove property properly for boolean properties', () => {
304
DOMPropertyOperations.setValueForProperty(
305
stubNode,
306
'hidden',
@@ -316,7 +316,7 @@ describe('DOMPropertyOperations', function() {
316
expect(stubNode.hasAttribute('hidden')).toBe(false);
317
});
318
319
- it('should remove property properly even with different name', function() {
319
+ it('should remove property properly even with different name', () => {
320
// Suppose 'foobar' is a property that corresponds to the underlying
321
// 'className' property:
322
DOMProperty.injection.injectDOMPropertyConfig({
@@ -348,17 +348,17 @@ describe('DOMPropertyOperations', function() {
348
349
});
350
351
- describe('deleteValueForProperty', function() {
351
+ describe('deleteValueForProperty', () => {
352
var stubNode;
353
var stubInstance;
354
355
- beforeEach(function() {
355
+ beforeEach(() => {
356
stubNode = document.createElement('div');
357
stubInstance = {_debugID: 1};
358
ReactDOMComponentTree.precacheNode(stubInstance, stubNode);
359
});
360
361
- it('should remove attributes for normal properties', function() {
361
+ it('should remove attributes for normal properties', () => {
362
DOMPropertyOperations.setValueForProperty(stubNode, 'title', 'foo');
363
expect(stubNode.getAttribute('title')).toBe('foo');
364
expect(stubNode.title).toBe('foo');
@@ -369,7 +369,7 @@ describe('DOMPropertyOperations', function() {
369
//expect(stubNode.title).toBe('');
370
});
371
372
- it('should not remove attributes for special properties', function() {
372
+ it('should not remove attributes for special properties', () => {
373
stubNode = document.createElement('input');
374
ReactDOMComponentTree.precacheNode(stubInstance, stubNode);
375
@@ -381,7 +381,7 @@ describe('DOMPropertyOperations', function() {
381
expect(stubNode.value).toBe('');
382
});
383
384
- it('should not leave all options selected when deleting multiple', function() {
384
+ it('should not leave all options selected when deleting multiple', () => {
385
stubNode = document.createElement('select');
386
ReactDOMComponentTree.precacheNode(stubInstance, stubNode);
387
@@ -402,8 +402,8 @@ describe('DOMPropertyOperations', function() {
402
});
403
});
404
405
- describe('injectDOMPropertyConfig', function() {
406
- it('should support custom attributes', function() {
405
+ describe('injectDOMPropertyConfig', () => {
406
+ it('should support custom attributes', () => {
407
// foobar does not exist yet
408
expect(DOMPropertyOperations.createMarkupForProperty(
409
'foobar',
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+94
-94
@@ -12,7 +12,7 @@
12
'use strict';
13
14
15
-describe('ReactDOMComponent', function() {
15
+describe('ReactDOMComponent', () => {
16
var React;
17
var ReactDOM;
18
var ReactDOMFeatureFlags;
@@ -23,7 +23,7 @@ describe('ReactDOMComponent', function() {
23
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
24
}
25
26
- beforeEach(function() {
26
+ beforeEach(() => {
27
jest.resetModuleRegistry();
28
React = require('React');
29
ReactDOM = require('ReactDOM');
@@ -32,14 +32,14 @@ describe('ReactDOMComponent', function() {
32
inputValueTracking = require('inputValueTracking');
33
});
34
35
- describe('updateDOM', function() {
35
+ describe('updateDOM', () => {
36
var ReactTestUtils;
37
38
- beforeEach(function() {
38
+ beforeEach(() => {
39
ReactTestUtils = require('ReactTestUtils');
40
});
41
42
- it('should handle className', function() {
42
+ it('should handle className', () => {
43
var container = document.createElement('div');
44
ReactDOM.render(<div style={{}} />, container);
45
@@ -51,7 +51,7 @@ describe('ReactDOMComponent', function() {
51
expect(container.firstChild.className).toEqual('');
52
});
53
54
- it('should gracefully handle various style value types', function() {
54
+ it('should gracefully handle various style value types', () => {
55
var container = document.createElement('div');
56
ReactDOM.render(<div style={{}} />, container);
57
var stubStyle = container.firstChild.style;
@@ -73,7 +73,7 @@ describe('ReactDOMComponent', function() {
73
});
74
75
// TODO: (poshannessy) deprecate this pattern.
76
- it('should update styles when mutating style object', function() {
76
+ it('should update styles when mutating style object', () => {
77
// not actually used. Just to suppress the style mutation warning
78
spyOn(console, 'error');
79
@@ -112,7 +112,7 @@ describe('ReactDOMComponent', function() {
112
expect(stubStyle.lineHeight).toBe('');
113
});
114
115
- it('should warn when mutating style', function() {
115
+ it('should warn when mutating style', () => {
116
spyOn(console, 'error');
117
118
var style = {border: '1px solid black'};
@@ -152,7 +152,7 @@ describe('ReactDOMComponent', function() {
152
expect(console.error.calls.count()).toBe(2);
153
});
154
155
- it('should warn for unknown prop', function() {
155
+ it('should warn for unknown prop', () => {
156
spyOn(console, 'error');
157
var container = document.createElement('div');
158
ReactDOM.render(<div foo="bar" />, container);
@@ -163,7 +163,7 @@ describe('ReactDOMComponent', function() {
163
);
164
});
165
166
- it('should group multiple unknown prop warnings together', function() {
166
+ it('should group multiple unknown prop warnings together', () => {
167
spyOn(console, 'error');
168
var container = document.createElement('div');
169
ReactDOM.render(<div foo="bar" baz="qux" />, container);
@@ -174,7 +174,7 @@ describe('ReactDOMComponent', function() {
174
);
175
});
176
177
- it('should warn for onDblClick prop', function() {
177
+ it('should warn for onDblClick prop', () => {
178
spyOn(console, 'error');
179
var container = document.createElement('div');
180
ReactDOM.render(<div onDblClick={() => {}} />, container);
@@ -184,7 +184,7 @@ describe('ReactDOMComponent', function() {
184
);
185
});
186
187
- it('should not warn for "0" as a unitless style value', function() {
187
+ it('should not warn for "0" as a unitless style value', () => {
188
spyOn(console, 'error');
189
190
class Component extends React.Component {
@@ -197,7 +197,7 @@ describe('ReactDOMComponent', function() {
197
expect(console.error.calls.count()).toBe(0);
198
});
199
200
- it('should warn nicely about NaN in style', function() {
200
+ it('should warn nicely about NaN in style', () => {
201
spyOn(console, 'error');
202
203
var style = {fontSize: NaN};
@@ -211,7 +211,7 @@ describe('ReactDOMComponent', function() {
211
);
212
});
213
214
- it('should update styles if initially null', function() {
214
+ it('should update styles if initially null', () => {
215
var styles = null;
216
var container = document.createElement('div');
217
ReactDOM.render(<div style={styles} />, container);
@@ -224,7 +224,7 @@ describe('ReactDOMComponent', function() {
224
expect(stubStyle.display).toEqual('block');
225
});
226
227
- it('should update styles if updated to null multiple times', function() {
227
+ it('should update styles if updated to null multiple times', () => {
228
var styles = null;
229
var container = document.createElement('div');
230
ReactDOM.render(<div style={styles} />, container);
@@ -245,7 +245,7 @@ describe('ReactDOMComponent', function() {
245
expect(stubStyle.display).toEqual('');
246
});
247
248
- it('should skip reserved props on web components', function() {
248
+ it('should skip reserved props on web components', () => {
249
var container = document.createElement('div');
250
251
ReactDOM.render(
@@ -273,7 +273,7 @@ describe('ReactDOMComponent', function() {
273
).toBe(false);
274
});
275
276
- it('should skip dangerouslySetInnerHTML on web components', function() {
276
+ it('should skip dangerouslySetInnerHTML on web components', () => {
277
var container = document.createElement('div');
278
279
ReactDOM.render(
@@ -293,7 +293,7 @@ describe('ReactDOMComponent', function() {
293
).toBe(false);
294
});
295
296
- it('should remove attributes', function() {
296
+ it('should remove attributes', () => {
297
var container = document.createElement('div');
298
ReactDOM.render(<img height="17" />, container);
299
@@ -302,7 +302,7 @@ describe('ReactDOMComponent', function() {
302
expect(container.firstChild.hasAttribute('height')).toBe(false);
303
});
304
305
- it('should remove properties', function() {
305
+ it('should remove properties', () => {
306
var container = document.createElement('div');
307
ReactDOM.render(<div className="monkey" />, container);
308
@@ -311,7 +311,7 @@ describe('ReactDOMComponent', function() {
311
expect(container.firstChild.className).toEqual('');
312
});
313
314
- it('should properly update custom attributes on custom elements', function() {
314
+ it('should properly update custom attributes on custom elements', () => {
315
var container = document.createElement('div');
316
ReactDOM.render(<some-custom-element foo="bar"/>, container);
317
ReactDOM.render(<some-custom-element bar="buzz"/>, container);
@@ -320,7 +320,7 @@ describe('ReactDOMComponent', function() {
320
expect(node.getAttribute('bar')).toBe('buzz');
321
});
322
323
- it('should clear a single style prop when changing `style`', function() {
323
+ it('should clear a single style prop when changing `style`', () => {
324
var styles = {display: 'none', color: 'red'};
325
var container = document.createElement('div');
326
ReactDOM.render(<div style={styles} />, container);
@@ -333,7 +333,7 @@ describe('ReactDOMComponent', function() {
333
expect(stubStyle.color).toEqual('green');
334
});
335
336
- it('should reject attribute key injection attack on markup', function() {
336
+ it('should reject attribute key injection attack on markup', () => {
337
spyOn(console, 'error');
338
for (var i = 0; i < 3; i++) {
339
var container = document.createElement('div');
@@ -350,7 +350,7 @@ describe('ReactDOMComponent', function() {
350
);
351
});
352
353
- it('should reject attribute key injection attack on update', function() {
353
+ it('should reject attribute key injection attack on update', () => {
354
spyOn(console, 'error');
355
for (var i = 0; i < 3; i++) {
356
var container = document.createElement('div');
@@ -370,7 +370,7 @@ describe('ReactDOMComponent', function() {
370
);
371
});
372
373
- it('should update arbitrary attributes for tags containing dashes', function() {
373
+ it('should update arbitrary attributes for tags containing dashes', () => {
374
var container = document.createElement('div');
375
376
var beforeUpdate = React.createElement('x-foo-component', {}, null);
@@ -382,7 +382,7 @@ describe('ReactDOMComponent', function() {
382
expect(container.childNodes[0].getAttribute('myattr')).toBe('myval');
383
});
384
385
- it('should clear all the styles when removing `style`', function() {
385
+ it('should clear all the styles when removing `style`', () => {
386
var styles = {display: 'none', color: 'red'};
387
var container = document.createElement('div');
388
ReactDOM.render(<div style={styles} />, container);
@@ -394,7 +394,7 @@ describe('ReactDOMComponent', function() {
394
expect(stubStyle.color).toEqual('');
395
});
396
397
- it('should update styles when `style` changes from null to object', function() {
397
+ it('should update styles when `style` changes from null to object', () => {
398
var container = document.createElement('div');
399
var styles = {color: 'red'};
400
ReactDOM.render(<div style={styles} />, container);
@@ -405,7 +405,7 @@ describe('ReactDOMComponent', function() {
405
expect(stubStyle.color).toEqual('red');
406
});
407
408
- it('should empty element when removing innerHTML', function() {
408
+ it('should empty element when removing innerHTML', () => {
409
var container = document.createElement('div');
410
ReactDOM.render(<div dangerouslySetInnerHTML={{__html: ':)'}} />, container);
411
@@ -414,7 +414,7 @@ describe('ReactDOMComponent', function() {
414
expect(container.firstChild.innerHTML).toEqual('');
415
});
416
417
- it('should transition from string content to innerHTML', function() {
417
+ it('should transition from string content to innerHTML', () => {
418
var container = document.createElement('div');
419
ReactDOM.render(<div>hello</div>, container);
420
@@ -426,7 +426,7 @@ describe('ReactDOMComponent', function() {
426
expect(container.firstChild.innerHTML).toEqual('goodbye');
427
});
428
429
- it('should transition from innerHTML to string content', function() {
429
+ it('should transition from innerHTML to string content', () => {
430
var container = document.createElement('div');
431
ReactDOM.render(
432
<div dangerouslySetInnerHTML={{__html: 'bonjour'}} />,
@@ -438,7 +438,7 @@ describe('ReactDOMComponent', function() {
438
expect(container.firstChild.innerHTML).toEqual('adieu');
439
});
440
441
- it('should transition from innerHTML to children in nested el', function() {
441
+ it('should transition from innerHTML to children in nested el', () => {
442
var container = document.createElement('div');
443
ReactDOM.render(
444
<div><div dangerouslySetInnerHTML={{__html: 'bonjour'}} /></div>,
@@ -450,7 +450,7 @@ describe('ReactDOMComponent', function() {
450
expect(container.textContent).toEqual('adieu');
451
});
452
453
- it('should transition from children to innerHTML in nested el', function() {
453
+ it('should transition from children to innerHTML in nested el', () => {
454
var container = document.createElement('div');
455
ReactDOM.render(<div><div><span>adieu</span></div></div>, container);
456
@@ -462,7 +462,7 @@ describe('ReactDOMComponent', function() {
462
expect(container.textContent).toEqual('bonjour');
463
});
464
465
- it('should not incur unnecessary DOM mutations for attributes', function() {
465
+ it('should not incur unnecessary DOM mutations for attributes', () => {
466
var container = document.createElement('div');
467
ReactDOM.render(<div id="" />, container);
468
@@ -500,7 +500,7 @@ describe('ReactDOMComponent', function() {
500
expect(node.removeAttribute.mock.calls.length).toBe(2);
501
});
502
503
- it('should not incur unnecessary DOM mutations for string properties', function() {
503
+ it('should not incur unnecessary DOM mutations for string properties', () => {
504
var container = document.createElement('div');
505
ReactDOM.render(<div value="" />, container);
506
@@ -533,7 +533,7 @@ describe('ReactDOMComponent', function() {
533
expect(nodeValueSetter.mock.calls.length).toBe(2);
534
});
535
536
- it('should not incur unnecessary DOM mutations for boolean properties', function() {
536
+ it('should not incur unnecessary DOM mutations for boolean properties', () => {
537
var container = document.createElement('div');
538
ReactDOM.render(<div checked={true} />, container);
539
@@ -562,13 +562,13 @@ describe('ReactDOMComponent', function() {
562
expect(nodeValueSetter.mock.calls.length).toBe(3);
563
});
564
565
- it('should ignore attribute whitelist for elements with the "is: attribute', function() {
565
+ it('should ignore attribute whitelist for elements with the "is: attribute', () => {
566
var container = document.createElement('div');
567
ReactDOM.render(<button is="test" cowabunga="chevynova"/>, container);
568
expect(container.firstChild.hasAttribute('cowabunga')).toBe(true);
569
});
570
571
- it('should not update when switching between null/undefined', function() {
571
+ it('should not update when switching between null/undefined', () => {
572
var container = document.createElement('div');
573
var node = ReactDOM.render(<div />, container);
574
@@ -583,7 +583,7 @@ describe('ReactDOMComponent', function() {
583
expect(setter.mock.calls.length).toBe(1);
584
});
585
586
- it('handles multiple child updates without interference', function() {
586
+ it('handles multiple child updates without interference', () => {
587
// This test might look like it's just testing ReactMultiChild but the
588
// last bug in this was actually in DOMChildrenOperations so this test
589
// needs to be in some DOM-specific test file.
@@ -618,14 +618,14 @@ describe('ReactDOMComponent', function() {
618
});
619
});
620
621
- describe('createOpenTagMarkup', function() {
621
+ describe('createOpenTagMarkup', () => {
622
var genMarkup;
623
624
function quoteRegexp(str) {
625
return (str + '').replace(/([.?*+\^$\[\]\\(){}|-])/g, '\\$1');
626
}
627
628
- beforeEach(function() {
628
+ beforeEach(() => {
629
var ReactDefaultInjection = require('ReactDefaultInjection');
630
ReactDefaultInjection.inject();
631
@@ -664,27 +664,27 @@ describe('ReactDOMComponent', function() {
664
});
665
});
666
667
- it('should generate the correct markup with className', function() {
667
+ it('should generate the correct markup with className', () => {
668
expect(genMarkup({className: 'a'})).toHaveAttribute(['class', 'a']);
669
expect(genMarkup({className: 'a b'})).toHaveAttribute(['class', 'a b']);
670
expect(genMarkup({className: ''})).toHaveAttribute(['class', '']);
671
});
672
673
- it('should escape style names and values', function() {
673
+ it('should escape style names and values', () => {
674
expect(genMarkup({
675
style: {'b&ckground': '<3'},
676
})).toHaveAttribute(['style', 'b&ckground:<3;']);
677
});
678
});
679
680
- describe('createContentMarkup', function() {
680
+ describe('createContentMarkup', () => {
681
var genMarkup;
682
683
function quoteRegexp(str) {
684
return (str + '').replace(/([.?*+\^$\[\]\\(){}|-])/g, '\\$1');
685
}
686
687
- beforeEach(function() {
687
+ beforeEach(() => {
688
var ReactDOMComponent = require('ReactDOMComponent');
689
var ReactReconcileTransaction = require('ReactReconcileTransaction');
690
@@ -717,7 +717,7 @@ describe('ReactDOMComponent', function() {
717
});
718
});
719
720
- it('should handle dangerouslySetInnerHTML', function() {
720
+ it('should handle dangerouslySetInnerHTML', () => {
721
var innerHTML = {__html: 'testContent'};
722
expect(
723
genMarkup({dangerouslySetInnerHTML: innerHTML})
@@ -725,17 +725,17 @@ describe('ReactDOMComponent', function() {
725
});
726
});
727
728
- describe('mountComponent', function() {
728
+ describe('mountComponent', () => {
729
var mountComponent;
730
731
- beforeEach(function() {
731
+ beforeEach(() => {
732
mountComponent = function(props) {
733
var container = document.createElement('div');
734
ReactDOM.render(<div {...props} />, container);
735
};
736
});
737
738
- it('should work error event on <source> element', function() {
738
+ it('should work error event on <source> element', () => {
739
spyOn(console, 'error');
740
var container = document.createElement('div');
741
ReactDOM.render(
@@ -755,7 +755,7 @@ describe('ReactDOMComponent', function() {
755
);
756
});
757
758
- it('should not duplicate uppercased selfclosing tags', function() {
758
+ it('should not duplicate uppercased selfclosing tags', () => {
759
class Container extends React.Component {
760
render() {
761
return React.createElement('BR', null);
@@ -766,7 +766,7 @@ describe('ReactDOMComponent', function() {
766
expect(returnedValue).not.toContain('</BR>');
767
});
768
769
- it('should warn against children for void elements', function() {
769
+ it('should warn against children for void elements', () => {
770
var container = document.createElement('div');
771
772
expect(function() {
@@ -777,7 +777,7 @@ describe('ReactDOMComponent', function() {
777
);
778
});
779
780
- it('should warn against dangerouslySetInnerHTML for void elements', function() {
780
+ it('should warn against dangerouslySetInnerHTML for void elements', () => {
781
var container = document.createElement('div');
782
783
expect(function() {
@@ -791,7 +791,7 @@ describe('ReactDOMComponent', function() {
791
);
792
});
793
794
- it('should treat menuitem as a void element but still create the closing tag', function() {
794
+ it('should treat menuitem as a void element but still create the closing tag', () => {
795
var container = document.createElement('div');
796
797
var returnedValue = ReactDOMServer.renderToString(<menu><menuitem /></menu>);
@@ -807,7 +807,7 @@ describe('ReactDOMComponent', function() {
807
808
});
809
810
- it('should validate against multiple children props', function() {
810
+ it('should validate against multiple children props', () => {
811
expect(function() {
812
mountComponent({children: '', dangerouslySetInnerHTML: ''});
813
}).toThrowError(
@@ -815,7 +815,7 @@ describe('ReactDOMComponent', function() {
815
);
816
});
817
818
- it('should validate against use of innerHTML', function() {
818
+ it('should validate against use of innerHTML', () => {
819
820
spyOn(console, 'error');
821
mountComponent({innerHTML: '<span>Hi Jim!</span>'});
@@ -825,7 +825,7 @@ describe('ReactDOMComponent', function() {
825
);
826
});
827
828
- it('should validate use of dangerouslySetInnerHTML', function() {
828
+ it('should validate use of dangerouslySetInnerHTML', () => {
829
expect(function() {
830
mountComponent({dangerouslySetInnerHTML: '<span>Hi Jim!</span>'});
831
}).toThrowError(
@@ -834,7 +834,7 @@ describe('ReactDOMComponent', function() {
834
);
835
});
836
837
- it('should validate use of dangerouslySetInnerHTML', function() {
837
+ it('should validate use of dangerouslySetInnerHTML', () => {
838
expect(function() {
839
mountComponent({dangerouslySetInnerHTML: {foo: 'bar'} });
840
}).toThrowError(
@@ -843,26 +843,26 @@ describe('ReactDOMComponent', function() {
843
);
844
});
845
846
- it('should allow {__html: null}', function() {
846
+ it('should allow {__html: null}', () => {
847
expect(function() {
848
mountComponent({dangerouslySetInnerHTML: {__html: null} });
849
}).not.toThrow();
850
});
851
852
- it('should warn about contentEditable and children', function() {
852
+ it('should warn about contentEditable and children', () => {
853
spyOn(console, 'error');
854
mountComponent({contentEditable: true, children: ''});
855
expect(console.error.calls.count()).toBe(1);
856
expect(console.error.calls.argsFor(0)[0]).toContain('contentEditable');
857
});
858
859
- it('should respect suppressContentEditableWarning', function() {
859
+ it('should respect suppressContentEditableWarning', () => {
860
spyOn(console, 'error');
861
mountComponent({contentEditable: true, children: '', suppressContentEditableWarning: true});
862
expect(console.error.calls.count()).toBe(0);
863
});
864
865
- it('should validate against invalid styles', function() {
865
+ it('should validate against invalid styles', () => {
866
expect(function() {
867
mountComponent({style: 'display: none'});
868
}).toThrowError(
@@ -872,7 +872,7 @@ describe('ReactDOMComponent', function() {
872
);
873
});
874
875
- it('should track input values', function() {
875
+ it('should track input values', () => {
876
var container = document.createElement('div');
877
var inst = ReactDOM.render(<input type="text" defaultValue="foo"/>, container);
878
@@ -881,7 +881,7 @@ describe('ReactDOMComponent', function() {
881
expect(tracker.getValue()).toEqual('foo');
882
});
883
884
- it('should track textarea values', function() {
884
+ it('should track textarea values', () => {
885
var container = document.createElement('div');
886
var inst = ReactDOM.render(<textarea defaultValue="foo"/>, container);
887
@@ -890,7 +890,7 @@ describe('ReactDOMComponent', function() {
890
expect(tracker.getValue()).toEqual('foo');
891
});
892
893
- it('should execute custom event plugin listening behavior', function() {
893
+ it('should execute custom event plugin listening behavior', () => {
894
var SimpleEventPlugin = require('SimpleEventPlugin');
895
896
SimpleEventPlugin.didPutListener = jest.fn();
@@ -909,7 +909,7 @@ describe('ReactDOMComponent', function() {
909
expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(1);
910
});
911
912
- it('should handle null and missing properly with event hooks', function() {
912
+ it('should handle null and missing properly with event hooks', () => {
913
var SimpleEventPlugin = require('SimpleEventPlugin');
914
915
SimpleEventPlugin.didPutListener = jest.fn();
@@ -945,7 +945,7 @@ describe('ReactDOMComponent', function() {
945
expect(SimpleEventPlugin.willDeleteListener.mock.calls.length).toBe(1);
946
});
947
948
- it('should warn for children on void elements', function() {
948
+ it('should warn for children on void elements', () => {
949
class X extends React.Component {
950
render() {
951
return <input>moo</input>;
@@ -961,7 +961,7 @@ describe('ReactDOMComponent', function() {
961
);
962
});
963
964
- it('should support custom elements which extend native elements', function() {
964
+ it('should support custom elements which extend native elements', () => {
965
if (ReactDOMFeatureFlags.useCreateElement) {
966
var container = document.createElement('div');
967
spyOn(document, 'createElement').and.callThrough();
@@ -973,14 +973,14 @@ describe('ReactDOMComponent', function() {
973
});
974
});
975
976
- describe('updateComponent', function() {
976
+ describe('updateComponent', () => {
977
var container;
978
979
- beforeEach(function() {
979
+ beforeEach(() => {
980
container = document.createElement('div');
981
});
982
983
- it('should warn against children for void elements', function() {
983
+ it('should warn against children for void elements', () => {
984
ReactDOM.render(<input />, container);
985
986
expect(function() {
@@ -991,7 +991,7 @@ describe('ReactDOMComponent', function() {
991
);
992
});
993
994
- it('should warn against dangerouslySetInnerHTML for void elements', function() {
994
+ it('should warn against dangerouslySetInnerHTML for void elements', () => {
995
ReactDOM.render(<input />, container);
996
997
expect(function() {
@@ -1005,7 +1005,7 @@ describe('ReactDOMComponent', function() {
1005
);
1006
});
1007
1008
- it('should validate against multiple children props', function() {
1008
+ it('should validate against multiple children props', () => {
1009
ReactDOM.render(<div></div>, container);
1010
1011
expect(function() {
@@ -1018,7 +1018,7 @@ describe('ReactDOMComponent', function() {
1018
);
1019
});
1020
1021
- it('should warn about contentEditable and children', function() {
1021
+ it('should warn about contentEditable and children', () => {
1022
spyOn(console, 'error');
1023
ReactDOM.render(
1024
<div contentEditable={true}><div /></div>,
@@ -1028,7 +1028,7 @@ describe('ReactDOMComponent', function() {
1028
expect(console.error.calls.argsFor(0)[0]).toContain('contentEditable');
1029
});
1030
1031
- it('should validate against invalid styles', function() {
1031
+ it('should validate against invalid styles', () => {
1032
ReactDOM.render(<div></div>, container);
1033
1034
expect(function() {
@@ -1040,7 +1040,7 @@ describe('ReactDOMComponent', function() {
1040
);
1041
});
1042
1043
- it('should report component containing invalid styles', function() {
1043
+ it('should report component containing invalid styles', () => {
1044
class Animal extends React.Component {
1045
render() {
1046
return <div style={1}></div>;
@@ -1056,7 +1056,7 @@ describe('ReactDOMComponent', function() {
1056
);
1057
});
1058
1059
- it('should properly escape text content and attributes values', function() {
1059
+ it('should properly escape text content and attributes values', () => {
1060
expect(
1061
ReactDOMServer.renderToStaticMarkup(
1062
React.DOM.div({
@@ -1074,8 +1074,8 @@ describe('ReactDOMComponent', function() {
1074
});
1075
});
1076
1077
- describe('unmountComponent', function() {
1078
- it('should clean up listeners', function() {
1077
+ describe('unmountComponent', () => {
1078
+ it('should clean up listeners', () => {
1079
var EventPluginHub = require('EventPluginHub');
1080
var ReactDOMComponentTree = require('ReactDOMComponentTree');
1081
@@ -1100,7 +1100,7 @@ describe('ReactDOMComponent', function() {
1100
).toBe(undefined);
1101
});
1102
1103
- it('should clean up input value tracking', function() {
1103
+ it('should clean up input value tracking', () => {
1104
var container = document.createElement('div');
1105
var node = ReactDOM.render(<input type="text" defaultValue="foo"/>, container);
1106
var tracker = inputValueTracking._getTrackerFromNode(node);
@@ -1112,7 +1112,7 @@ describe('ReactDOMComponent', function() {
1112
expect(tracker.stopTracking.calls.count()).toBe(1);
1113
});
1114
1115
- it('should clean up input textarea tracking', function() {
1115
+ it('should clean up input textarea tracking', () => {
1116
var container = document.createElement('div');
1117
var node = ReactDOM.render(<textarea defaultValue="foo"/>, container);
1118
var tracker = inputValueTracking._getTrackerFromNode(node);
@@ -1124,7 +1124,7 @@ describe('ReactDOMComponent', function() {
1124
expect(tracker.stopTracking.calls.count()).toBe(1);
1125
});
1126
1127
- it('unmounts children before unsetting DOM node info', function() {
1127
+ it('unmounts children before unsetting DOM node info', () => {
1128
class Inner extends React.Component {
1129
render() {
1130
return <span />;
@@ -1142,7 +1142,7 @@ describe('ReactDOMComponent', function() {
1142
});
1143
});
1144
1145
- describe('onScroll warning', function() {
1145
+ describe('onScroll warning', () => {
1146
it('should warn about the `onScroll` issue when unsupported (IE8)', () => {
1147
// Mock this here so we can mimic IE8 support. We require isEventSupported
1148
// before React so it's pre-mocked before React would require it.
@@ -1161,14 +1161,14 @@ describe('ReactDOMComponent', function() {
1161
);
1162
});
1163
1164
- it('should not warn when server-side rendering `onScroll`', function() {
1164
+ it('should not warn when server-side rendering `onScroll`', () => {
1165
spyOn(console, 'error');
1166
ReactDOMServer.renderToString(<div onScroll={() => {}}/>);
1167
expect(console.error).not.toHaveBeenCalled();
1168
});
1169
});
1170
1171
- describe('tag sanitization', function() {
1171
+ describe('tag sanitization', () => {
1172
it('should throw when an invalid tag name is used', () => {
1173
var ReactTestUtils = require('ReactTestUtils');
1174
var hackzor = React.createElement('script tag');
@@ -1190,10 +1190,10 @@ describe('ReactDOMComponent', function() {
1190
});
1191
});
1192
1193
- describe('nesting validation', function() {
1193
+ describe('nesting validation', () => {
1194
var ReactTestUtils;
1195
1196
- beforeEach(function() {
1196
+ beforeEach(() => {
1197
ReactTestUtils = require('ReactTestUtils');
1198
});
1199
@@ -1331,14 +1331,14 @@ describe('ReactDOMComponent', function() {
1331
);
1332
});
1333
1334
- it('should warn about incorrect casing on properties (ssr)', function() {
1334
+ it('should warn about incorrect casing on properties (ssr)', () => {
1335
spyOn(console, 'error');
1336
ReactDOMServer.renderToString(React.createElement('input', {type: 'text', tabindex: '1'}));
1337
expect(console.error.calls.count()).toBe(1);
1338
expect(console.error.calls.argsFor(0)[0]).toContain('tabIndex');
1339
});
1340
1341
- it('should warn about incorrect casing on event handlers (ssr)', function() {
1341
+ it('should warn about incorrect casing on event handlers (ssr)', () => {
1342
spyOn(console, 'error');
1343
ReactDOMServer.renderToString(React.createElement('input', {type: 'text', onclick: '1'}));
1344
ReactDOMServer.renderToString(React.createElement('input', {type: 'text', onKeydown: '1'}));
@@ -1347,14 +1347,14 @@ describe('ReactDOMComponent', function() {
1347
expect(console.error.calls.argsFor(1)[0]).toContain('onKeyDown');
1348
});
1349
1350
- it('should warn about incorrect casing on properties', function() {
1350
+ it('should warn about incorrect casing on properties', () => {
1351
spyOn(console, 'error');
1352
ReactTestUtils.renderIntoDocument(React.createElement('input', {type: 'text', tabindex: '1'}));
1353
expect(console.error.calls.count()).toBe(1);
1354
expect(console.error.calls.argsFor(0)[0]).toContain('tabIndex');
1355
});
1356
1357
- it('should warn about incorrect casing on event handlers', function() {
1357
+ it('should warn about incorrect casing on event handlers', () => {
1358
spyOn(console, 'error');
1359
ReactTestUtils.renderIntoDocument(React.createElement('input', {type: 'text', onclick: '1'}));
1360
ReactTestUtils.renderIntoDocument(React.createElement('input', {type: 'text', onKeydown: '1'}));
@@ -1363,14 +1363,14 @@ describe('ReactDOMComponent', function() {
1363
expect(console.error.calls.argsFor(1)[0]).toContain('onKeyDown');
1364
});
1365
1366
- it('should warn about class', function() {
1366
+ it('should warn about class', () => {
1367
spyOn(console, 'error');
1368
ReactDOMServer.renderToString(React.createElement('div', {class: 'muffins'}));
1369
expect(console.error.calls.count()).toBe(1);
1370
expect(console.error.calls.argsFor(0)[0]).toContain('className');
1371
});
1372
1373
- it('should warn about props that are no longer supported', function() {
1373
+ it('should warn about props that are no longer supported', () => {
1374
spyOn(console, 'error');
1375
ReactTestUtils.renderIntoDocument(<div />);
1376
expect(console.error.calls.count()).toBe(0);
@@ -1382,7 +1382,7 @@ describe('ReactDOMComponent', function() {
1382
expect(console.error.calls.count()).toBe(2);
1383
});
1384
1385
- it('gives source code refs for unknown prop warning', function() {
1385
+ it('gives source code refs for unknown prop warning', () => {
1386
spyOn(console, 'error');
1387
ReactDOMServer.renderToString(<div class="paladin"/>);
1388
ReactDOMServer.renderToString(<input type="text" onclick="1"/>);
@@ -1400,7 +1400,7 @@ describe('ReactDOMComponent', function() {
1400
);
1401
});
1402
1403
- it('gives source code refs for unknown prop warning for update render', function() {
1403
+ it('gives source code refs for unknown prop warning for update render', () => {
1404
spyOn(console, 'error');
1405
var container = document.createElement('div');
1406
@@ -1417,7 +1417,7 @@ describe('ReactDOMComponent', function() {
1417
1418
});
1419
1420
- it('gives source code refs for unknown prop warning for exact elements ', function() {
1420
+ it('gives source code refs for unknown prop warning for exact elements ', () => {
1421
spyOn(console, 'error');
1422
1423
ReactDOMServer.renderToString(
@@ -1445,7 +1445,7 @@ describe('ReactDOMComponent', function() {
1445
expect(parseInt(previousLine, 10) + 2).toBe(parseInt(currentLine, 10));
1446
});
1447
1448
- it('gives source code refs for unknown prop warning for exact elements in composition ', function() {
1448
+ it('gives source code refs for unknown prop warning for exact elements in composition ', () => {
1449
spyOn(console, 'error');
1450
var container = document.createElement('div');
1451
src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
+7
-7
@@ -15,14 +15,14 @@ var React;
15
var ReactDOM;
16
var ReactDOMServer;
17
18
-describe('ReactDOMTextComponent', function() {
19
- beforeEach(function() {
18
+describe('ReactDOMTextComponent', () => {
19
+ beforeEach(() => {
20
React = require('React');
21
ReactDOM = require('ReactDOM');
22
ReactDOMServer = require('ReactDOMServer');
23
});
24
25
- it('updates a mounted text component in place', function() {
25
+ it('updates a mounted text component in place', () => {
26
var el = document.createElement('div');
27
var inst = ReactDOM.render(<div><span />{'foo'}{'bar'}</div>, el);
28
@@ -40,7 +40,7 @@ describe('ReactDOMTextComponent', function() {
40
expect(bar.data).toBe('qux');
41
});
42
43
- it('can be toggled in and out of the markup', function() {
43
+ it('can be toggled in and out of the markup', () => {
44
var el = document.createElement('div');
45
var inst = ReactDOM.render(<div>{'foo'}<div />{'bar'}</div>, el);
46
@@ -63,7 +63,7 @@ describe('ReactDOMTextComponent', function() {
63
expect(childNodes[5].data).toBe('bar');
64
});
65
66
- it('can reconcile text merged by Node.normalize()', function() {
66
+ it('can reconcile text merged by Node.normalize()', () => {
67
var el = document.createElement('div');
68
var inst = ReactDOM.render(<div>{'foo'}{'bar'}{'baz'}</div>, el);
69
@@ -75,7 +75,7 @@ describe('ReactDOMTextComponent', function() {
75
expect(container.textContent).toBe('barbazqux');
76
});
77
78
- it('can reconcile text from pre-rendered markup', function() {
78
+ it('can reconcile text from pre-rendered markup', () => {
79
var el = document.createElement('div');
80
var reactEl = <div>{'foo'}{'bar'}{'baz'}</div>;
81
el.innerHTML = ReactDOMServer.renderToString(reactEl);
@@ -90,7 +90,7 @@ describe('ReactDOMTextComponent', function() {
90
expect(el.textContent).toBe('');
91
});
92
93
- it('can reconcile text arbitrarily split into multiple nodes', function() {
93
+ it('can reconcile text arbitrarily split into multiple nodes', () => {
94
var el = document.createElement('div');
95
var inst = ReactDOM.render(<div><span />{'foobarbaz'}</div>, el);
96
src/renderers/dom/shared/__tests__/escapeTextContentForBrowser-test.js
+5
-5
@@ -11,16 +11,16 @@
11
12
'use strict';
13
14
-describe('escapeTextContentForBrowser', function() {
14
+describe('escapeTextContentForBrowser', () => {
15
16
var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
17
18
- it('should escape boolean to string', function() {
18
+ it('should escape boolean to string', () => {
19
expect(escapeTextContentForBrowser(true)).toBe('true');
20
expect(escapeTextContentForBrowser(false)).toBe('false');
21
});
22
23
- it('should escape object to string', function() {
23
+ it('should escape object to string', () => {
24
var escaped = escapeTextContentForBrowser({
25
toString: function() {
26
return 'ponys';
@@ -30,11 +30,11 @@ describe('escapeTextContentForBrowser', function() {
30
expect(escaped).toBe('ponys');
31
});
32
33
- it('should escape number to string', function() {
33
+ it('should escape number to string', () => {
34
expect(escapeTextContentForBrowser(42)).toBe('42');
35
});
36
37
- it('should escape string', function() {
37
+ it('should escape string', () => {
38
var escaped = escapeTextContentForBrowser('<script type=\'\' src=""></script>');
39
expect(escaped).not.toContain('<');
40
expect(escaped).not.toContain('>');
src/renderers/dom/shared/__tests__/quoteAttributeValueForBrowser-test.js
+5
-5
@@ -11,16 +11,16 @@
11
12
'use strict';
13
14
-describe('quoteAttributeValueForBrowser', function() {
14
+describe('quoteAttributeValueForBrowser', () => {
15
16
var quoteAttributeValueForBrowser = require('quoteAttributeValueForBrowser');
17
18
- it('should escape boolean to string', function() {
18
+ it('should escape boolean to string', () => {
19
expect(quoteAttributeValueForBrowser(true)).toBe('"true"');
20
expect(quoteAttributeValueForBrowser(false)).toBe('"false"');
21
});
22
23
- it('should escape object to string', function() {
23
+ it('should escape object to string', () => {
24
var escaped = quoteAttributeValueForBrowser({
25
toString: function() {
26
return 'ponys';
@@ -30,11 +30,11 @@ describe('quoteAttributeValueForBrowser', function() {
30
expect(escaped).toBe('"ponys"');
31
});
32
33
- it('should escape number to string', function() {
33
+ it('should escape number to string', () => {
34
expect(quoteAttributeValueForBrowser(42)).toBe('"42"');
35
});
36
37
- it('should escape string', function() {
37
+ it('should escape string', () => {
38
var escaped = quoteAttributeValueForBrowser('<script type=\'\' src=""></script>');
39
expect(escaped).not.toContain('<');
40
expect(escaped).not.toContain('>');
src/renderers/native/__tests__/ReactNativeAttributePayload-test.js
+1
-1
@@ -14,7 +14,7 @@ var ReactNativePropRegistry = require('ReactNativePropRegistry');
14
15
var diff = ReactNativeAttributePayload.diff;
16
17
-describe('ReactNativeAttributePayload', function() {
17
+describe('ReactNativeAttributePayload', () => {
18
19
it('should work with simple example', () => {
20
expect(diff(
src/renderers/native/__tests__/ReactNativeMount-test.js
+4
-4
@@ -16,15 +16,15 @@ var ReactNative;
16
var createReactNativeComponentClass;
17
var UIManager;
18
19
-describe('ReactNative', function() {
20
- beforeEach(function() {
19
+describe('ReactNative', () => {
20
+ beforeEach(() => {
21
React = require('React');
22
ReactNative = require('ReactNative');
23
UIManager = require('UIManager');
24
createReactNativeComponentClass = require('createReactNativeComponentClass');
25
});
26
27
- it('should be able to create and render a native component', function() {
27
+ it('should be able to create and render a native component', () => {
28
var View = createReactNativeComponentClass({
29
validAttributes: { foo: true },
30
uiViewClassName: 'View',
@@ -37,7 +37,7 @@ describe('ReactNative', function() {
37
expect(UIManager.updateView).not.toBeCalled();
38
});
39
40
- it('should be able to create and update a native component', function() {
40
+ it('should be able to create and update a native component', () => {
41
var View = createReactNativeComponentClass({
42
validAttributes: { foo: true },
43
uiViewClassName: 'View',
src/renderers/shared/__tests__/ReactDebugTool-test.js
+2
-2
@@ -11,10 +11,10 @@
11
12
'use strict';
13
14
-describe('ReactDebugTool', function() {
14
+describe('ReactDebugTool', () => {
15
var ReactDebugTool;
16
17
- beforeEach(function() {
17
+ beforeEach(() => {
18
jest.resetModuleRegistry();
19
ReactDebugTool = require('ReactDebugTool');
20
});
src/renderers/shared/__tests__/ReactPerf-test.js
+24
-24
@@ -11,7 +11,7 @@
11
12
'use strict';
13
14
-describe('ReactPerf', function() {
14
+describe('ReactPerf', () => {
15
var React;
16
var ReactDOM;
17
var ReactPerf;
@@ -23,7 +23,7 @@ describe('ReactPerf', function() {
23
var Div;
24
var LifeCycle;
25
26
- beforeEach(function() {
26
+ beforeEach(() => {
27
var now = 0;
28
jest.setMock('fbjs/lib/performanceNow', function() {
29
return now++;
@@ -71,7 +71,7 @@ describe('ReactPerf', function() {
71
});
72
});
73
74
- afterEach(function() {
74
+ afterEach(() => {
75
if (console.table.isFake) {
76
delete console.table;
77
}
@@ -91,7 +91,7 @@ describe('ReactPerf', function() {
91
return ReactPerf.getLastMeasurements();
92
}
93
94
- it('should count no-op update as waste', function() {
94
+ it('should count no-op update as waste', () => {
95
var container = document.createElement('div');
96
ReactDOM.render(<App />, container);
97
var measurements = measure(() => {
@@ -112,7 +112,7 @@ describe('ReactPerf', function() {
112
}]);
113
});
114
115
- it('should count no-op update in child as waste', function() {
115
+ it('should count no-op update in child as waste', () => {
116
var container = document.createElement('div');
117
ReactDOM.render(<App />, container);
118
@@ -137,13 +137,13 @@ describe('ReactPerf', function() {
137
expect(summary).toEqual([]);
138
}
139
140
- it('should not count initial render as waste', function() {
140
+ it('should not count initial render as waste', () => {
141
expectNoWaste(() => {
142
ReactTestUtils.renderIntoDocument(<App />);
143
});
144
});
145
146
- it('should not count unmount as waste', function() {
146
+ it('should not count unmount as waste', () => {
147
var container = document.createElement('div');
148
ReactDOM.render(<Div>hello</Div>, container);
149
expectNoWaste(() => {
@@ -151,7 +151,7 @@ describe('ReactPerf', function() {
151
});
152
});
153
154
- it('should not count content update as waste', function() {
154
+ it('should not count content update as waste', () => {
155
var container = document.createElement('div');
156
ReactDOM.render(<Div>hello</Div>, container);
157
expectNoWaste(() => {
@@ -159,7 +159,7 @@ describe('ReactPerf', function() {
159
});
160
});
161
162
- it('should not count child addition as waste', function() {
162
+ it('should not count child addition as waste', () => {
163
var container = document.createElement('div');
164
ReactDOM.render(<Div><span /></Div>, container);
165
expectNoWaste(() => {
@@ -167,7 +167,7 @@ describe('ReactPerf', function() {
167
});
168
});
169
170
- it('should not count child removal as waste', function() {
170
+ it('should not count child removal as waste', () => {
171
var container = document.createElement('div');
172
ReactDOM.render(<Div><span /><span /></Div>, container);
173
expectNoWaste(() => {
@@ -175,7 +175,7 @@ describe('ReactPerf', function() {
175
});
176
});
177
178
- it('should not count property update as waste', function() {
178
+ it('should not count property update as waste', () => {
179
var container = document.createElement('div');
180
ReactDOM.render(<Div className="yellow">hey</Div>, container);
181
expectNoWaste(() => {
@@ -183,7 +183,7 @@ describe('ReactPerf', function() {
183
});
184
});
185
186
- it('should not count style update as waste', function() {
186
+ it('should not count style update as waste', () => {
187
var container = document.createElement('div');
188
ReactDOM.render(<Div style={{color: 'yellow'}}>hey</Div>, container);
189
expectNoWaste(() => {
@@ -191,7 +191,7 @@ describe('ReactPerf', function() {
191
});
192
});
193
194
- it('should not count property removal as waste', function() {
194
+ it('should not count property removal as waste', () => {
195
var container = document.createElement('div');
196
ReactDOM.render(<Div className="yellow">hey</Div>, container);
197
expectNoWaste(() => {
@@ -199,7 +199,7 @@ describe('ReactPerf', function() {
199
});
200
});
201
202
- it('should not count raw HTML update as waste', function() {
202
+ it('should not count raw HTML update as waste', () => {
203
var container = document.createElement('div');
204
ReactDOM.render(
205
<Div dangerouslySetInnerHTML={{__html: 'me'}} />,
@@ -213,7 +213,7 @@ describe('ReactPerf', function() {
213
});
214
});
215
216
- it('should not count child reordering as waste', function() {
216
+ it('should not count child reordering as waste', () => {
217
var container = document.createElement('div');
218
ReactDOM.render(<Div><div key="A" /><div key="B" /></Div>, container);
219
expectNoWaste(() => {
@@ -221,7 +221,7 @@ describe('ReactPerf', function() {
221
});
222
});
223
224
- it('should not count text update as waste', function() {
224
+ it('should not count text update as waste', () => {
225
var container = document.createElement('div');
226
ReactDOM.render(<Div>{'hello'}{'world'}</Div>, container);
227
expectNoWaste(() => {
@@ -229,7 +229,7 @@ describe('ReactPerf', function() {
229
});
230
});
231
232
- it('should not count replacing null with a host as waste', function() {
232
+ it('should not count replacing null with a host as waste', () => {
233
var element = null;
234
function Foo() {
235
return element;
@@ -242,7 +242,7 @@ describe('ReactPerf', function() {
242
});
243
});
244
245
- it('should not count replacing a host with null as waste', function() {
245
+ it('should not count replacing a host with null as waste', () => {
246
var element = <div />;
247
function Foo() {
248
return element;
@@ -255,7 +255,7 @@ describe('ReactPerf', function() {
255
});
256
});
257
258
- it('should include stats for components unmounted during measurement', function() {
258
+ it('should include stats for components unmounted during measurement', () => {
259
var container = document.createElement('div');
260
var measurements = measure(() => {
261
ReactDOM.render(<Div><Div key="a" /></Div>, container);
@@ -270,7 +270,7 @@ describe('ReactPerf', function() {
270
}]);
271
});
272
273
- it('should include lifecycle methods in measurements', function() {
273
+ it('should include lifecycle methods in measurements', () => {
274
var container = document.createElement('div');
275
var measurements = measure(() => {
276
var instance = ReactDOM.render(<LifeCycle />, container);
@@ -307,7 +307,7 @@ describe('ReactPerf', function() {
307
}]);
308
});
309
310
- it('should include render time of functional components', function() {
310
+ it('should include render time of functional components', () => {
311
function Foo() {
312
return null;
313
}
@@ -329,7 +329,7 @@ describe('ReactPerf', function() {
329
}]);
330
});
331
332
- it('should not count time in a portal towards lifecycle method', function() {
332
+ it('should not count time in a portal towards lifecycle method', () => {
333
function Foo() {
334
return null;
335
}
@@ -385,7 +385,7 @@ describe('ReactPerf', function() {
385
}]);
386
});
387
388
- it('warns once when using getMeasurementsSummaryMap', function() {
388
+ it('warns once when using getMeasurementsSummaryMap', () => {
389
var measurements = measure(() => {});
390
spyOn(console, 'error');
391
ReactPerf.getMeasurementsSummaryMap(measurements);
@@ -399,7 +399,7 @@ describe('ReactPerf', function() {
399
expect(console.error.calls.count()).toBe(1);
400
});
401
402
- it('warns once when using printDOM', function() {
402
+ it('warns once when using printDOM', () => {
403
var measurements = measure(() => {});
404
spyOn(console, 'error');
405
ReactPerf.printDOM(measurements);
src/renderers/shared/fiber/__tests__/ReactCoroutine-test.js
+3
-3
@@ -15,14 +15,14 @@ var React;
15
var ReactNoop;
16
var ReactCoroutine;
17
18
-describe('ReactCoroutine', function() {
19
- beforeEach(function() {
18
+describe('ReactCoroutine', () => {
19
+ beforeEach(() => {
20
React = require('React');
21
ReactNoop = require('ReactNoop');
22
ReactCoroutine = require('ReactCoroutine');
23
});
24
25
- it('should render a coroutine', function() {
25
+ it('should render a coroutine', () => {
26
27
var ops = [];
28
src/renderers/shared/fiber/__tests__/ReactIncremental-test.js
+11
-11
@@ -14,13 +14,13 @@
14
var React;
15
var ReactNoop;
16
17
-describe('ReactIncremental', function() {
18
- beforeEach(function() {
17
+describe('ReactIncremental', () => {
18
+ beforeEach(() => {
19
React = require('React');
20
ReactNoop = require('ReactNoop');
21
});
22
23
- it('should render a simple component', function() {
23
+ it('should render a simple component', () => {
24
25
function Bar() {
26
return <div>Hello World</div>;
@@ -35,7 +35,7 @@ describe('ReactIncremental', function() {
35
36
});
37
38
- it('should render a simple component, in steps if needed', function() {
38
+ it('should render a simple component, in steps if needed', () => {
39
40
var barCalled = false;
41
function Bar() {
@@ -65,7 +65,7 @@ describe('ReactIncremental', function() {
65
expect(barCalled).toBe(true);
66
});
67
68
- it('updates a previous render', function() {
68
+ it('updates a previous render', () => {
69
70
var ops = [];
71
@@ -116,7 +116,7 @@ describe('ReactIncremental', function() {
116
117
});
118
119
- it('can cancel partially rendered work and restart', function() {
119
+ it('can cancel partially rendered work and restart', () => {
120
121
var ops = [];
122
@@ -164,7 +164,7 @@ describe('ReactIncremental', function() {
164
165
});
166
167
- it('can deprioritize unfinished work and resume it later', function() {
167
+ it('can deprioritize unfinished work and resume it later', () => {
168
169
var ops = [];
170
@@ -218,7 +218,7 @@ describe('ReactIncremental', function() {
218
219
});
220
221
- it('can resume work in a subtree even when a parent bails out', function() {
221
+ it('can resume work in a subtree even when a parent bails out', () => {
222
223
var ops = [];
224
@@ -282,7 +282,7 @@ describe('ReactIncremental', function() {
282
expect(ops).toEqual(['Middle']);
283
});
284
285
- it('can resume work in a bailed subtree within one pass', function() {
285
+ it('can resume work in a bailed subtree within one pass', () => {
286
var ops = [];
287
288
function Bar(props) {
@@ -362,7 +362,7 @@ describe('ReactIncremental', function() {
362
expect(ops).toEqual(['Bar', 'Middle', 'Bar']);
363
});
364
365
- it('can reuse work done after being preempted', function() {
365
+ it('can reuse work done after being preempted', () => {
366
367
var ops = [];
368
@@ -461,7 +461,7 @@ describe('ReactIncremental', function() {
461
462
});
463
464
- it('can reuse work if shouldComponentUpdate is false, after being preempted', function() {
464
+ it('can reuse work if shouldComponentUpdate is false, after being preempted', () => {
465
466
var ops = [];
467
src/renderers/shared/fiber/__tests__/ReactIncrementalSideEffects-test.js
+8
-8
@@ -14,8 +14,8 @@
14
var React;
15
var ReactNoop;
16
17
-describe('ReactIncrementalSideEffects', function() {
18
- beforeEach(function() {
17
+describe('ReactIncrementalSideEffects', () => {
18
+ beforeEach(() => {
19
React = require('React');
20
ReactNoop = require('ReactNoop');
21
});
@@ -28,7 +28,7 @@ describe('ReactIncrementalSideEffects', function() {
28
return { type: 'span', children: [], prop };
29
}
30
31
- it('can update child nodes of a host instance', function() {
31
+ it('can update child nodes of a host instance', () => {
32
33
function Bar(props) {
34
return <span>{props.text}</span>;
@@ -57,7 +57,7 @@ describe('ReactIncrementalSideEffects', function() {
57
58
});
59
60
- it('does not update child nodes if a flush is aborted', function() {
60
+ it('does not update child nodes if a flush is aborted', () => {
61
62
function Bar(props) {
63
return <span prop={props.text} />;
@@ -89,7 +89,7 @@ describe('ReactIncrementalSideEffects', function() {
89
90
});
91
92
- it('preserves a previously rendered node when deprioritized', function() {
92
+ it('preserves a previously rendered node when deprioritized', () => {
93
94
function Middle(props) {
95
return <span prop={props.children} />;
@@ -127,7 +127,7 @@ describe('ReactIncrementalSideEffects', function() {
127
128
});
129
130
- it('can reuse side-effects after being preempted', function() {
130
+ it('can reuse side-effects after being preempted', () => {
131
132
function Bar(props) {
133
return <span prop={props.children} />;
@@ -188,7 +188,7 @@ describe('ReactIncrementalSideEffects', function() {
188
]);
189
});
190
191
- it('can reuse side-effects after being preempted, if shouldComponentUpdate is false', function() {
191
+ it('can reuse side-effects after being preempted, if shouldComponentUpdate is false', () => {
192
193
class Bar extends React.Component {
194
shouldComponentUpdate(nextProps) {
@@ -254,7 +254,7 @@ describe('ReactIncrementalSideEffects', function() {
254
]);
255
});
256
257
- it('updates a child even though the old props is empty', function() {
257
+ it('updates a child even though the old props is empty', () => {
258
function Foo(props) {
259
return (
260
<div hidden={true}>
src/renderers/shared/stack/event/__tests__/EventPluginHub-test.js
+3
-3
@@ -13,18 +13,18 @@
13
14
jest.mock('isEventSupported');
15
16
-describe('EventPluginHub', function() {
16
+describe('EventPluginHub', () => {
17
var EventPluginHub;
18
var isEventSupported;
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
jest.resetModuleRegistry();
22
EventPluginHub = require('EventPluginHub');
23
isEventSupported = require('isEventSupported');
24
isEventSupported.mockReturnValueOnce(false);
25
});
26
27
- it('should prevent non-function listeners', function() {
27
+ it('should prevent non-function listeners', () => {
28
expect(function() {
29
EventPluginHub.putListener(1, 'onClick', 'not a function');
30
}).toThrowError(
src/renderers/shared/stack/event/__tests__/EventPluginRegistry-test.js
+13
-13
@@ -12,11 +12,11 @@
12
'use strict';
13
14
15
-describe('EventPluginRegistry', function() {
15
+describe('EventPluginRegistry', () => {
16
var EventPluginRegistry;
17
var createPlugin;
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
EventPluginRegistry = require('EventPluginRegistry');
21
EventPluginRegistry._resetEventPlugins();
22
@@ -25,7 +25,7 @@ describe('EventPluginRegistry', function() {
25
};
26
});
27
28
- it('should be able to inject ordering before plugins', function() {
28
+ it('should be able to inject ordering before plugins', () => {
29
var OnePlugin = createPlugin();
30
var TwoPlugin = createPlugin();
31
var ThreePlugin = createPlugin();
@@ -45,7 +45,7 @@ describe('EventPluginRegistry', function() {
45
expect(EventPluginRegistry.plugins[2]).toBe(ThreePlugin);
46
});
47
48
- it('should be able to inject plugins before and after ordering', function() {
48
+ it('should be able to inject plugins before and after ordering', () => {
49
var OnePlugin = createPlugin();
50
var TwoPlugin = createPlugin();
51
var ThreePlugin = createPlugin();
@@ -65,7 +65,7 @@ describe('EventPluginRegistry', function() {
65
expect(EventPluginRegistry.plugins[2]).toBe(ThreePlugin);
66
});
67
68
- it('should be able to inject repeated plugins and out-of-order', function() {
68
+ it('should be able to inject repeated plugins and out-of-order', () => {
69
var OnePlugin = createPlugin();
70
var TwoPlugin = createPlugin();
71
var ThreePlugin = createPlugin();
@@ -86,7 +86,7 @@ describe('EventPluginRegistry', function() {
86
expect(EventPluginRegistry.plugins[2]).toBe(ThreePlugin);
87
});
88
89
- it('should throw if plugin does not implement `extractEvents`', function() {
89
+ it('should throw if plugin does not implement `extractEvents`', () => {
90
var BadPlugin = {};
91
92
EventPluginRegistry.injectEventPluginOrder(['bad']);
@@ -101,7 +101,7 @@ describe('EventPluginRegistry', function() {
101
);
102
});
103
104
- it('should throw if plugin does not exist in ordering', function() {
104
+ it('should throw if plugin does not exist in ordering', () => {
105
var OnePlugin = createPlugin();
106
var RandomPlugin = createPlugin();
107
@@ -118,7 +118,7 @@ describe('EventPluginRegistry', function() {
118
);
119
});
120
121
- it('should throw if ordering is injected more than once', function() {
121
+ it('should throw if ordering is injected more than once', () => {
122
var pluginOrdering = [];
123
124
EventPluginRegistry.injectEventPluginOrder(pluginOrdering);
@@ -131,7 +131,7 @@ describe('EventPluginRegistry', function() {
131
);
132
});
133
134
- it('should throw if different plugins injected using same name', function() {
134
+ it('should throw if different plugins injected using same name', () => {
135
var OnePlugin = createPlugin();
136
var TwoPlugin = createPlugin();
137
@@ -145,7 +145,7 @@ describe('EventPluginRegistry', function() {
145
);
146
});
147
148
- it('should publish registration names of injected plugins', function() {
148
+ it('should publish registration names of injected plugins', () => {
149
var OnePlugin = createPlugin({
150
eventTypes: {
151
click: {registrationName: 'onClick'},
@@ -179,7 +179,7 @@ describe('EventPluginRegistry', function() {
179
).toBe(TwoPlugin);
180
});
181
182
- it('should throw if multiple registration names collide', function() {
182
+ it('should throw if multiple registration names collide', () => {
183
var OnePlugin = createPlugin({
184
eventTypes: {
185
photoCapture: {registrationName: 'onPhotoCapture'},
@@ -209,7 +209,7 @@ describe('EventPluginRegistry', function() {
209
);
210
});
211
212
- it('should throw if an invalid event is published', function() {
212
+ it('should throw if an invalid event is published', () => {
213
var OnePlugin = createPlugin({
214
eventTypes: {
215
badEvent: {/* missing configuration */},
@@ -226,7 +226,7 @@ describe('EventPluginRegistry', function() {
226
);
227
});
228
229
- it('should be able to get the plugin from synthetic events', function() {
229
+ it('should be able to get the plugin from synthetic events', () => {
230
var clickDispatchConfig = {
231
registrationName: 'onClick',
232
};
src/renderers/shared/stack/event/eventPlugins/__tests__/ResponderEventPlugin-test.js
+3
-3
@@ -327,8 +327,8 @@ var siblings = {
327
childTwo: CHILD_ID2,
328
};
329
330
-describe('ResponderEventPlugin', function() {
331
- beforeEach(function() {
330
+describe('ResponderEventPlugin', () => {
331
+ beforeEach(() => {
332
jest.resetModuleRegistry();
333
334
EventPluginHub = require('EventPluginHub');
@@ -378,7 +378,7 @@ describe('ResponderEventPlugin', function() {
378
});
379
});
380
381
- it('should do nothing when no one wants to respond', function() {
381
+ it('should do nothing when no one wants to respond', () => {
382
var config = oneEventLoopTestConfig(three);
383
config.startShouldSetResponder.captured.grandParent = {order: 0, returnVal: false};
384
config.startShouldSetResponder.captured.parent = {order: 1, returnVal: false};
src/renderers/shared/stack/reconciler/__tests__/ReactChildReconciler-test.js
+4
-4
@@ -17,19 +17,19 @@
17
var React;
18
var ReactTestUtils;
19
20
-describe('ReactChildReconciler', function() {
20
+describe('ReactChildReconciler', () => {
21
function normalizeCodeLocInfo(str) {
22
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
23
}
24
25
- beforeEach(function() {
25
+ beforeEach(() => {
26
jest.resetModuleRegistry();
27
28
React = require('React');
29
ReactTestUtils = require('ReactTestUtils');
30
});
31
32
- it('warns for duplicated keys', function() {
32
+ it('warns for duplicated keys', () => {
33
spyOn(console, 'error');
34
35
class Component extends React.Component {
@@ -46,7 +46,7 @@ describe('ReactChildReconciler', function() {
46
);
47
});
48
49
- it('warns for duplicated keys with component stack info', function() {
49
+ it('warns for duplicated keys with component stack info', () => {
50
spyOn(console, 'error');
51
52
class Component extends React.Component {
src/renderers/shared/stack/reconciler/__tests__/ReactComponent-test.js
+13
-13
@@ -19,14 +19,14 @@ function normalizeCodeLocInfo(str) {
19
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
20
}
21
22
-describe('ReactComponent', function() {
23
- beforeEach(function() {
22
+describe('ReactComponent', () => {
23
+ beforeEach(() => {
24
React = require('React');
25
ReactDOM = require('ReactDOM');
26
ReactTestUtils = require('ReactTestUtils');
27
});
28
29
- it('should throw on invalid render targets', function() {
29
+ it('should throw on invalid render targets', () => {
30
var container = document.createElement('div');
31
// jQuery objects are basically arrays; people often pass them in by mistake
32
expect(function() {
@@ -42,14 +42,14 @@ describe('ReactComponent', function() {
42
);
43
});
44
45
- it('should throw when supplying a ref outside of render method', function() {
45
+ it('should throw when supplying a ref outside of render method', () => {
46
var instance = <div ref="badDiv" />;
47
expect(function() {
48
instance = ReactTestUtils.renderIntoDocument(instance);
49
}).toThrow();
50
});
51
52
- it('should warn when children are mutated before render', function() {
52
+ it('should warn when children are mutated before render', () => {
53
spyOn(console, 'error');
54
var children = [<span key={0} />, <span key={1} />, <span key={2} />];
55
var element = <div>{children}</div>;
@@ -61,7 +61,7 @@ describe('ReactComponent', function() {
61
);
62
});
63
64
- it('should warn when children are mutated', function() {
64
+ it('should warn when children are mutated', () => {
65
spyOn(console, 'error');
66
var children = [<span key={0} />, <span key={1} />, <span key={2} />];
67
function Wrapper(props) {
@@ -75,7 +75,7 @@ describe('ReactComponent', function() {
75
);
76
});
77
78
- it('should support refs on owned components', function() {
78
+ it('should support refs on owned components', () => {
79
var innerObj = {};
80
var outerObj = {};
81
@@ -106,7 +106,7 @@ describe('ReactComponent', function() {
106
instance = ReactTestUtils.renderIntoDocument(instance);
107
});
108
109
- it('should not have refs on unmounted components', function() {
109
+ it('should not have refs on unmounted components', () => {
110
class Parent extends React.Component {
111
render() {
112
return <Child><div ref="test" /></Child>;
@@ -127,7 +127,7 @@ describe('ReactComponent', function() {
127
instance = ReactTestUtils.renderIntoDocument(instance);
128
});
129
130
- it('should support new-style refs', function() {
130
+ it('should support new-style refs', () => {
131
var innerObj = {};
132
var outerObj = {};
133
@@ -166,7 +166,7 @@ describe('ReactComponent', function() {
166
expect(mounted).toBe(true);
167
});
168
169
- it('should support new-style refs with mixed-up owners', function() {
169
+ it('should support new-style refs with mixed-up owners', () => {
170
class Wrapper extends React.Component {
171
getTitle = () => {
172
return this.props.title;
@@ -209,7 +209,7 @@ describe('ReactComponent', function() {
209
expect(mounted).toBe(true);
210
});
211
212
- it('should call refs at the correct time', function() {
212
+ it('should call refs at the correct time', () => {
213
var log = [];
214
215
class Inner extends React.Component {
@@ -298,7 +298,7 @@ describe('ReactComponent', function() {
298
/* eslint-enable indent */
299
});
300
301
- it('fires the callback after a component is rendered', function() {
301
+ it('fires the callback after a component is rendered', () => {
302
var callback = jest.fn();
303
var container = document.createElement('div');
304
ReactDOM.render(<div />, container, callback);
@@ -309,7 +309,7 @@ describe('ReactComponent', function() {
309
expect(callback.mock.calls.length).toBe(3);
310
});
311
312
- it('throws usefully when rendering badly-typed elements', function() {
312
+ it('throws usefully when rendering badly-typed elements', () => {
313
spyOn(console, 'error');
314
315
var X = undefined;
src/renderers/shared/stack/reconciler/__tests__/ReactComponentLifeCycle-test.js
+15
-15
@@ -93,8 +93,8 @@ function getLifeCycleState(instance): ComponentLifeCycle {
93
* is *reused*, then that won't be the case and things will appear to work in
94
* some cases. Better to just block all updates in initialization.
95
*/
96
-describe('ReactComponentLifeCycle', function() {
97
- beforeEach(function() {
96
+describe('ReactComponentLifeCycle', () => {
97
+ beforeEach(() => {
98
jest.resetModuleRegistry();
99
React = require('React');
100
ReactDOM = require('ReactDOM');
@@ -102,7 +102,7 @@ describe('ReactComponentLifeCycle', function() {
102
ReactInstanceMap = require('ReactInstanceMap');
103
});
104
105
- it('should not reuse an instance when it has been unmounted', function() {
105
+ it('should not reuse an instance when it has been unmounted', () => {
106
var container = document.createElement('div');
107
108
class StatefulComponent extends React.Component {
@@ -126,7 +126,7 @@ describe('ReactComponentLifeCycle', function() {
126
* If a state update triggers rerendering that in turn fires an onDOMReady,
127
* that second onDOMReady should not fail.
128
*/
129
- it('it should fire onDOMReady when already in onDOMReady', function() {
129
+ it('it should fire onDOMReady when already in onDOMReady', () => {
130
var _testJournal = [];
131
132
class Child extends React.Component {
@@ -177,7 +177,7 @@ describe('ReactComponentLifeCycle', function() {
177
178
// You could assign state here, but not access members of it, unless you
179
// had provided a getInitialState method.
180
- it('throws when accessing state in componentWillMount', function() {
180
+ it('throws when accessing state in componentWillMount', () => {
181
class StatefulComponent extends React.Component {
182
componentWillMount() {
183
void this.state.yada;
@@ -196,7 +196,7 @@ describe('ReactComponentLifeCycle', function() {
196
}).toThrow();
197
});
198
199
- it('should allow update state inside of componentWillMount', function() {
199
+ it('should allow update state inside of componentWillMount', () => {
200
class StatefulComponent extends React.Component {
201
componentWillMount() {
202
this.setState({stateField: 'something'});
@@ -215,7 +215,7 @@ describe('ReactComponentLifeCycle', function() {
215
}).not.toThrow();
216
});
217
218
- it('should not allow update state inside of getInitialState', function() {
218
+ it('should not allow update state inside of getInitialState', () => {
219
spyOn(console, 'error');
220
221
class StatefulComponent extends React.Component {
@@ -243,7 +243,7 @@ describe('ReactComponentLifeCycle', function() {
243
);
244
});
245
246
- it('should correctly determine if a component is mounted', function() {
246
+ it('should correctly determine if a component is mounted', () => {
247
spyOn(console, 'error');
248
var Component = React.createClass({
249
componentWillMount: function() {
@@ -269,7 +269,7 @@ describe('ReactComponentLifeCycle', function() {
269
);
270
});
271
272
- it('should correctly determine if a null component is mounted', function() {
272
+ it('should correctly determine if a null component is mounted', () => {
273
spyOn(console, 'error');
274
var Component = React.createClass({
275
componentWillMount: function() {
@@ -295,7 +295,7 @@ describe('ReactComponentLifeCycle', function() {
295
);
296
});
297
298
- it('isMounted should return false when unmounted', function() {
298
+ it('isMounted should return false when unmounted', () => {
299
var Component = React.createClass({
300
render: function() {
301
return <div/>;
@@ -312,7 +312,7 @@ describe('ReactComponentLifeCycle', function() {
312
expect(instance.isMounted()).toBe(false);
313
});
314
315
- it('warns if findDOMNode is used inside render', function() {
315
+ it('warns if findDOMNode is used inside render', () => {
316
spyOn(console, 'error');
317
var Component = React.createClass({
318
getInitialState: function() {
@@ -336,7 +336,7 @@ describe('ReactComponentLifeCycle', function() {
336
);
337
});
338
339
- it('should carry through each of the phases of setup', function() {
339
+ it('should carry through each of the phases of setup', () => {
340
class LifeCycleComponent extends React.Component {
341
constructor(props, context) {
342
super(props, context);
@@ -455,7 +455,7 @@ describe('ReactComponentLifeCycle', function() {
455
expect(instance.state).toEqual(POST_WILL_UNMOUNT_STATE);
456
});
457
458
- it('should not throw when updating an auxiliary component', function() {
458
+ it('should not throw when updating an auxiliary component', () => {
459
class Tooltip extends React.Component {
460
render() {
461
return <div>{this.props.children}</div>;
@@ -503,7 +503,7 @@ describe('ReactComponentLifeCycle', function() {
503
);
504
});
505
506
- it('should allow state updates in componentDidMount', function() {
506
+ it('should allow state updates in componentDidMount', () => {
507
/**
508
* calls setState in an componentDidMount.
509
*/
@@ -530,7 +530,7 @@ describe('ReactComponentLifeCycle', function() {
530
expect(instance.state.stateField).toBe('goodbye');
531
});
532
533
- it('should call nested lifecycle methods in the right order', function() {
533
+ it('should call nested lifecycle methods in the right order', () => {
534
var log;
535
var logger = function(msg) {
536
return function() {
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js
+38
-38
@@ -23,9 +23,9 @@ var ReactUpdates;
23
24
var reactComponentExpect;
25
26
-describe('ReactCompositeComponent', function() {
26
+describe('ReactCompositeComponent', () => {
27
28
- beforeEach(function() {
28
+ beforeEach(() => {
29
jest.resetModuleRegistry();
30
reactComponentExpect = require('reactComponentExpect');
31
React = require('React');
@@ -69,7 +69,7 @@ describe('ReactCompositeComponent', function() {
69
};
70
});
71
72
- it('should support module pattern components', function() {
72
+ it('should support module pattern components', () => {
73
function Child({test}) {
74
return {
75
render() {
@@ -84,7 +84,7 @@ describe('ReactCompositeComponent', function() {
84
expect(el.textContent).toBe('test');
85
});
86
87
- it('should support rendering to different child types over time', function() {
87
+ it('should support rendering to different child types over time', () => {
88
var instance = <MorphingComponent />;
89
instance = ReactTestUtils.renderIntoDocument(instance);
90
@@ -123,7 +123,7 @@ describe('ReactCompositeComponent', function() {
123
ReactDOM.render(<Parent />, container);
124
});
125
126
- it('should react to state changes from callbacks', function() {
126
+ it('should react to state changes from callbacks', () => {
127
var instance = <MorphingComponent />;
128
instance = ReactTestUtils.renderIntoDocument(instance);
129
@@ -137,7 +137,7 @@ describe('ReactCompositeComponent', function() {
137
.toBeDOMComponentWithTag('b');
138
});
139
140
- it('should rewire refs when rendering to different child types', function() {
140
+ it('should rewire refs when rendering to different child types', () => {
141
var instance = <MorphingComponent />;
142
instance = ReactTestUtils.renderIntoDocument(instance);
143
@@ -148,7 +148,7 @@ describe('ReactCompositeComponent', function() {
148
expect(ReactDOM.findDOMNode(instance.refs.x).tagName).toBe('A');
149
});
150
151
- it('should not cache old DOM nodes when switching constructors', function() {
151
+ it('should not cache old DOM nodes when switching constructors', () => {
152
var container = document.createElement('div');
153
var instance = ReactDOM.render(
154
<ChildUpdates renderAnchor={true} anchorClassOn={false}/>,
@@ -169,7 +169,7 @@ describe('ReactCompositeComponent', function() {
169
expect(instance.getAnchor().className).toBe('');
170
});
171
172
- it('should auto bind methods and values correctly', function() {
172
+ it('should auto bind methods and values correctly', () => {
173
spyOn(console, 'error');
174
175
var ComponentClass = React.createClass({
@@ -215,7 +215,7 @@ describe('ReactCompositeComponent', function() {
215
216
});
217
218
- it('should not pass this to getDefaultProps', function() {
218
+ it('should not pass this to getDefaultProps', () => {
219
var Component = React.createClass({
220
getDefaultProps: function() {
221
expect(this.render).not.toBeDefined();
@@ -228,7 +228,7 @@ describe('ReactCompositeComponent', function() {
228
ReactTestUtils.renderIntoDocument(<Component />);
229
});
230
231
- it('should use default values for undefined props', function() {
231
+ it('should use default values for undefined props', () => {
232
class Component extends React.Component {
233
static defaultProps = {prop: 'testKey'};
234
@@ -250,7 +250,7 @@ describe('ReactCompositeComponent', function() {
250
reactComponentExpect(instance3).scalarPropsEqual({prop: null});
251
});
252
253
- it('should not mutate passed-in props object', function() {
253
+ it('should not mutate passed-in props object', () => {
254
class Component extends React.Component {
255
static defaultProps = {prop: 'testKey'};
256
@@ -269,7 +269,7 @@ describe('ReactCompositeComponent', function() {
269
expect(inputProps.prop).not.toBeDefined();
270
});
271
272
- it('should warn about `forceUpdate` on unmounted components', function() {
272
+ it('should warn about `forceUpdate` on unmounted components', () => {
273
spyOn(console, 'error');
274
275
var container = document.createElement('div');
@@ -301,7 +301,7 @@ describe('ReactCompositeComponent', function() {
301
);
302
});
303
304
- it('should warn about `setState` on unmounted components', function() {
304
+ it('should warn about `setState` on unmounted components', () => {
305
spyOn(console, 'error');
306
307
var container = document.createElement('div');
@@ -345,7 +345,7 @@ describe('ReactCompositeComponent', function() {
345
);
346
});
347
348
- it('should silently allow `setState`, not call cb on unmounting components', function() {
348
+ it('should silently allow `setState`, not call cb on unmounting components', () => {
349
var cbCalled = false;
350
var container = document.createElement('div');
351
document.body.appendChild(container);
@@ -374,7 +374,7 @@ describe('ReactCompositeComponent', function() {
374
});
375
376
377
- it('should warn about `setState` in render', function() {
377
+ it('should warn about `setState` in render', () => {
378
spyOn(console, 'error');
379
380
var container = document.createElement('div');
@@ -422,7 +422,7 @@ describe('ReactCompositeComponent', function() {
422
expect(instance2.state.value).toBe(1);
423
});
424
425
- it('should warn about `setState` in getChildContext', function() {
425
+ it('should warn about `setState` in getChildContext', () => {
426
spyOn(console, 'error');
427
428
var container = document.createElement('div');
@@ -454,7 +454,7 @@ describe('ReactCompositeComponent', function() {
454
);
455
});
456
457
- it('should cleanup even if render() fatals', function() {
457
+ it('should cleanup even if render() fatals', () => {
458
class BadComponent extends React.Component {
459
render() {
460
throw new Error();
@@ -472,7 +472,7 @@ describe('ReactCompositeComponent', function() {
472
expect(ReactCurrentOwner.current).toBe(null);
473
});
474
475
- it('should call componentWillUnmount before unmounting', function() {
475
+ it('should call componentWillUnmount before unmounting', () => {
476
var container = document.createElement('div');
477
var innerUnmounted = false;
478
@@ -502,7 +502,7 @@ describe('ReactCompositeComponent', function() {
502
expect(innerUnmounted).toBe(true);
503
});
504
505
- it('should warn when shouldComponentUpdate() returns undefined', function() {
505
+ it('should warn when shouldComponentUpdate() returns undefined', () => {
506
spyOn(console, 'error');
507
508
class Component extends React.Component {
@@ -527,7 +527,7 @@ describe('ReactCompositeComponent', function() {
527
);
528
});
529
530
- it('should warn when componentDidUnmount method is defined', function() {
530
+ it('should warn when componentDidUnmount method is defined', () => {
531
spyOn(console, 'error');
532
533
class Component extends React.Component {
@@ -549,7 +549,7 @@ describe('ReactCompositeComponent', function() {
549
);
550
});
551
552
- it('should pass context to children when not owner', function() {
552
+ it('should pass context to children when not owner', () => {
553
class Parent extends React.Component {
554
render() {
555
return <Child><Grandchild /></Child>;
@@ -586,7 +586,7 @@ describe('ReactCompositeComponent', function() {
586
expect(ReactDOM.findDOMNode(component).innerHTML).toBe('bar');
587
});
588
589
- it('should skip update when rerendering element in container', function() {
589
+ it('should skip update when rerendering element in container', () => {
590
class Parent extends React.Component {
591
render() {
592
return <div>{this.props.children}</div>;
@@ -610,7 +610,7 @@ describe('ReactCompositeComponent', function() {
610
expect(childRenders).toBe(1);
611
});
612
613
- it('should pass context when re-rendered for static child', function() {
613
+ it('should pass context when re-rendered for static child', () => {
614
var parentInstance = null;
615
var childInstance = null;
616
@@ -667,7 +667,7 @@ describe('ReactCompositeComponent', function() {
667
reactComponentExpect(childInstance).scalarContextEqual({foo: 'bar', flag: true});
668
});
669
670
- it('should pass context when re-rendered for static child within a composite component', function() {
670
+ it('should pass context when re-rendered for static child within a composite component', () => {
671
class Parent extends React.Component {
672
static childContextTypes = {
673
flag: ReactPropTypes.bool,
@@ -723,7 +723,7 @@ describe('ReactCompositeComponent', function() {
723
reactComponentExpect(wrapper.refs.child).scalarContextEqual({flag: false});
724
});
725
726
- it('should pass context transitively', function() {
726
+ it('should pass context transitively', () => {
727
var childInstance = null;
728
var grandchildInstance = null;
729
@@ -784,7 +784,7 @@ describe('ReactCompositeComponent', function() {
784
reactComponentExpect(grandchildInstance).scalarContextEqual({foo: 'bar', depth: 1});
785
});
786
787
- it('should pass context when re-rendered', function() {
787
+ it('should pass context when re-rendered', () => {
788
var parentInstance = null;
789
var childInstance = null;
790
@@ -838,7 +838,7 @@ describe('ReactCompositeComponent', function() {
838
reactComponentExpect(childInstance).scalarContextEqual({foo: 'bar', depth: 0});
839
});
840
841
- it('unmasked context propagates through updates', function() {
841
+ it('unmasked context propagates through updates', () => {
842
class Leaf extends React.Component {
843
static contextTypes = {
844
foo: ReactPropTypes.string.isRequired,
@@ -909,7 +909,7 @@ describe('ReactCompositeComponent', function() {
909
expect(div.children[0].id).toBe('aliens');
910
});
911
912
- it('should trigger componentWillReceiveProps for context changes', function() {
912
+ it('should trigger componentWillReceiveProps for context changes', () => {
913
var contextChanges = 0;
914
var propChanges = 0;
915
@@ -1024,7 +1024,7 @@ describe('ReactCompositeComponent', function() {
1024
expect(contextChanges).toBe(3); // ChildWithContext, GrandChild x 2
1025
});
1026
1027
- it('should disallow nested render calls', function() {
1027
+ it('should disallow nested render calls', () => {
1028
spyOn(console, 'error');
1029
1030
class Inner extends React.Component {
@@ -1050,7 +1050,7 @@ describe('ReactCompositeComponent', function() {
1050
);
1051
});
1052
1053
- it('only renders once if updated in componentWillReceiveProps', function() {
1053
+ it('only renders once if updated in componentWillReceiveProps', () => {
1054
var renders = 0;
1055
1056
class Component extends React.Component {
@@ -1076,7 +1076,7 @@ describe('ReactCompositeComponent', function() {
1076
expect(instance.state.updated).toBe(true);
1077
});
1078
1079
- it('should update refs if shouldComponentUpdate gives false', function() {
1079
+ it('should update refs if shouldComponentUpdate gives false', () => {
1080
class Static extends React.Component {
1081
shouldComponentUpdate() {
1082
return false;
@@ -1119,7 +1119,7 @@ describe('ReactCompositeComponent', function() {
1119
expect(ReactDOM.findDOMNode(comp.refs.static1).textContent).toBe('A');
1120
});
1121
1122
- it('should allow access to findDOMNode in componentWillUnmount', function() {
1122
+ it('should allow access to findDOMNode in componentWillUnmount', () => {
1123
var a = null;
1124
var b = null;
1125
@@ -1146,7 +1146,7 @@ describe('ReactCompositeComponent', function() {
1146
expect(a).toBe(b);
1147
});
1148
1149
- it('context should be passed down from the parent', function() {
1149
+ it('context should be passed down from the parent', () => {
1150
class Parent extends React.Component {
1151
static childContextTypes = {
1152
foo: ReactPropTypes.string,
@@ -1177,7 +1177,7 @@ describe('ReactCompositeComponent', function() {
1177
ReactDOM.render(<Parent><Component /></Parent>, div);
1178
});
1179
1180
- it('should replace state', function() {
1180
+ it('should replace state', () => {
1181
var Moo = React.createClass({
1182
getInitialState: function() {
1183
return {x: 1};
@@ -1193,7 +1193,7 @@ describe('ReactCompositeComponent', function() {
1193
expect(moo.state.y).toBe(2);
1194
});
1195
1196
- it('should support objects with prototypes as state', function() {
1196
+ it('should support objects with prototypes as state', () => {
1197
var NotActuallyImmutable = function(str) {
1198
this.str = str;
1199
};
@@ -1242,7 +1242,7 @@ describe('ReactCompositeComponent', function() {
1242
expect(moo.state.amIImmutable).toBe(undefined);
1243
});
1244
1245
- it('should not warn about unmounting during unmounting', function() {
1245
+ it('should not warn about unmounting during unmounting', () => {
1246
var container = document.createElement('div');
1247
var layer = document.createElement('div');
1248
@@ -1270,7 +1270,7 @@ describe('ReactCompositeComponent', function() {
1270
ReactDOM.render(<Outer />, container);
1271
});
1272
1273
- it('should warn when mutated props are passed', function() {
1273
+ it('should warn when mutated props are passed', () => {
1274
spyOn(console, 'error');
1275
1276
var container = document.createElement('div');
@@ -1298,7 +1298,7 @@ describe('ReactCompositeComponent', function() {
1298
1299
});
1300
1301
- it('should only call componentWillUnmount once', function() {
1301
+ it('should only call componentWillUnmount once', () => {
1302
var app;
1303
var count = 0;
1304
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponentDOMMinimalism-test.js
+5
-5
@@ -27,9 +27,9 @@ var expectSingleChildlessDiv;
27
* abstraction, `ReactCompositeComponent` does not ever add superfluous DOM
28
* nodes.
29
*/
30
-describe('ReactCompositeComponentDOMMinimalism', function() {
30
+describe('ReactCompositeComponentDOMMinimalism', () => {
31
32
- beforeEach(function() {
32
+ beforeEach(() => {
33
reactComponentExpect = require('reactComponentExpect');
34
React = require('React');
35
ReactTestUtils = require('ReactTestUtils');
@@ -64,7 +64,7 @@ describe('ReactCompositeComponentDOMMinimalism', function() {
64
};
65
});
66
67
- it('should not render extra nodes for non-interpolated text', function() {
67
+ it('should not render extra nodes for non-interpolated text', () => {
68
var instance = (
69
<MyCompositeComponent>
70
A string child
@@ -74,7 +74,7 @@ describe('ReactCompositeComponentDOMMinimalism', function() {
74
expectSingleChildlessDiv(instance);
75
});
76
77
- it('should not render extra nodes for non-interpolated text', function() {
77
+ it('should not render extra nodes for non-interpolated text', () => {
78
var instance = (
79
<MyCompositeComponent>
80
{'Interpolated String Child'}
@@ -84,7 +84,7 @@ describe('ReactCompositeComponentDOMMinimalism', function() {
84
expectSingleChildlessDiv(instance);
85
});
86
87
- it('should not render extra nodes for non-interpolated text', function() {
87
+ it('should not render extra nodes for non-interpolated text', () => {
88
var instance = (
89
<MyCompositeComponent>
90
<ul>
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponentNestedState-test.js
+3
-3
@@ -15,15 +15,15 @@ var React;
15
var ReactDOM;
16
var ReactTestUtils;
17
18
-describe('ReactCompositeComponentNestedState-state', function() {
18
+describe('ReactCompositeComponentNestedState-state', () => {
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
React = require('React');
22
ReactDOM = require('ReactDOM');
23
ReactTestUtils = require('ReactTestUtils');
24
});
25
26
- it('should provide up to date values for props', function() {
26
+ it('should provide up to date values for props', () => {
27
class ParentComponent extends React.Component {
28
state = {color: 'blue'};
29
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponentState-test.js
+4
-4
@@ -16,9 +16,9 @@ var ReactDOM;
16
17
var TestComponent;
18
19
-describe('ReactCompositeComponent-state', function() {
19
+describe('ReactCompositeComponent-state', () => {
20
21
- beforeEach(function() {
21
+ beforeEach(() => {
22
React = require('React');
23
24
ReactDOM = require('ReactDOM');
@@ -126,7 +126,7 @@ describe('ReactCompositeComponent-state', function() {
126
});
127
});
128
129
- it('should support setting state', function() {
129
+ it('should support setting state', () => {
130
var container = document.createElement('div');
131
document.body.appendChild(container);
132
@@ -216,7 +216,7 @@ describe('ReactCompositeComponent-state', function() {
216
].join('\n'));
217
});
218
219
- it('should batch unmounts', function() {
219
+ it('should batch unmounts', () => {
220
var outer;
221
222
class Inner extends React.Component {
src/renderers/shared/stack/reconciler/__tests__/ReactEmptyComponent-test.js
+6
-6
@@ -20,8 +20,8 @@ var reactComponentExpect;
20
21
var log;
22
23
-describe('ReactEmptyComponent', function() {
24
- beforeEach(function() {
23
+describe('ReactEmptyComponent', () => {
24
+ beforeEach(() => {
25
jest.resetModuleRegistry();
26
27
React = require('React');
@@ -202,7 +202,7 @@ describe('ReactEmptyComponent', function() {
202
}
203
);
204
205
- it('works when switching components', function() {
205
+ it('works when switching components', () => {
206
var assertions = 0;
207
208
class Inner extends React.Component {
@@ -249,7 +249,7 @@ describe('ReactEmptyComponent', function() {
249
expect(assertions).toBe(3);
250
});
251
252
- it('throws when rendering null at the top level', function() {
252
+ it('throws when rendering null at the top level', () => {
253
// TODO: This should actually work since `null` is a valid ReactNode
254
var div = document.createElement('div');
255
expect(function() {
@@ -259,7 +259,7 @@ describe('ReactEmptyComponent', function() {
259
);
260
});
261
262
- it('does not break when updating during mount', function() {
262
+ it('does not break when updating during mount', () => {
263
class Child extends React.Component {
264
componentDidMount() {
265
if (this.props.onMount) {
@@ -297,7 +297,7 @@ describe('ReactEmptyComponent', function() {
297
}).not.toThrow();
298
});
299
300
- it('preserves the dom node during updates', function() {
300
+ it('preserves the dom node during updates', () => {
301
class Empty extends React.Component {
302
render() {
303
return null;
src/renderers/shared/stack/reconciler/__tests__/ReactErrorBoundaries-test.js
+8
-8
@@ -14,14 +14,14 @@
14
var React;
15
var ReactDOM;
16
17
-describe('ReactErrorBoundaries', function() {
17
+describe('ReactErrorBoundaries', () => {
18
19
- beforeEach(function() {
19
+ beforeEach(() => {
20
ReactDOM = require('ReactDOM');
21
React = require('React');
22
});
23
24
- it('does not register event handlers for unmounted children', function() {
24
+ it('does not register event handlers for unmounted children', () => {
25
class Angry extends React.Component {
26
render() {
27
throw new Error('Please, do not render me.');
@@ -57,7 +57,7 @@ describe('ReactErrorBoundaries', function() {
57
expect(EventPluginHub.putListener).not.toBeCalled();
58
});
59
60
- it('renders an error state', function() {
60
+ it('renders an error state', () => {
61
var log = [];
62
class Angry extends React.Component {
63
render() {
@@ -112,7 +112,7 @@ describe('ReactErrorBoundaries', function() {
112
]);
113
});
114
115
- it('will catch exceptions in componentWillUnmount', function() {
115
+ it('will catch exceptions in componentWillUnmount', () => {
116
class ErrorBoundary extends React.Component {
117
constructor() {
118
super();
@@ -158,7 +158,7 @@ describe('ReactErrorBoundaries', function() {
158
ReactDOM.unmountComponentAtNode(container);
159
});
160
161
- it('expect uneventful render to succeed', function() {
161
+ it('expect uneventful render to succeed', () => {
162
var log = [];
163
class Boundary extends React.Component {
164
constructor(props) {
@@ -191,7 +191,7 @@ describe('ReactErrorBoundaries', function() {
191
]);
192
});
193
194
- it('correctly handles composite siblings', function() {
194
+ it('correctly handles composite siblings', () => {
195
class ErrorBoundary extends React.Component {
196
constructor() {
197
super();
@@ -226,7 +226,7 @@ describe('ReactErrorBoundaries', function() {
226
ReactDOM.unmountComponentAtNode(container);
227
});
228
229
- it('catches errors from children', function() {
229
+ it('catches errors from children', () => {
230
var log = [];
231
232
class Box extends React.Component {
src/renderers/shared/stack/reconciler/__tests__/ReactIdentity-test.js
+12
-12
@@ -16,9 +16,9 @@ var ReactDOM;
16
var ReactFragment;
17
var ReactTestUtils;
18
19
-describe('ReactIdentity', function() {
19
+describe('ReactIdentity', () => {
20
21
- beforeEach(function() {
21
+ beforeEach(() => {
22
jest.resetModuleRegistry();
23
React = require('React');
24
ReactDOM = require('ReactDOM');
@@ -30,7 +30,7 @@ describe('ReactIdentity', function() {
30
return ReactFragment.create(obj);
31
}
32
33
- it('should allow key property to express identity', function() {
33
+ it('should allow key property to express identity', () => {
34
var node;
35
var Component = (props) =>
36
<div ref={(c) => node = c}>
@@ -47,7 +47,7 @@ describe('ReactIdentity', function() {
47
expect(origChildren[1]).toBe(newChildren[0]);
48
});
49
50
- it('should use composite identity', function() {
50
+ it('should use composite identity', () => {
51
class Wrapper extends React.Component {
52
render() {
53
return <a>{this.props.children}</a>;
@@ -89,7 +89,7 @@ describe('ReactIdentity', function() {
89
expect(ReactDOM.findDOMNode(span2)).not.toBe(null);
90
}
91
92
- it('should allow any character as a key, in a detached parent', function() {
92
+ it('should allow any character as a key, in a detached parent', () => {
93
var detachedContainer = document.createElement('div');
94
renderAComponentWithKeyIntoContainer(
95
"<'WEIRD/&\\key'>",
@@ -97,7 +97,7 @@ describe('ReactIdentity', function() {
97
);
98
});
99
100
- it('should allow any character as a key, in an attached parent', function() {
100
+ it('should allow any character as a key, in an attached parent', () => {
101
// This test exists to protect against implementation details that
102
// incorrectly query escaped IDs using DOM tools like getElementById.
103
var attachedContainer = document.createElement('div');
@@ -111,7 +111,7 @@ describe('ReactIdentity', function() {
111
document.body.removeChild(attachedContainer);
112
});
113
114
- it('should not allow scripts in keys to execute', function() {
114
+ it('should not allow scripts in keys to execute', () => {
115
var h4x0rKey =
116
'"><script>window[\'YOUVEBEENH4X0RED\']=true;</script><div id="';
117
@@ -126,7 +126,7 @@ describe('ReactIdentity', function() {
126
expect(window.YOUVEBEENH4X0RED).toBe(undefined);
127
});
128
129
- it('should let restructured components retain their uniqueness', function() {
129
+ it('should let restructured components retain their uniqueness', () => {
130
var instance0 = <span />;
131
var instance1 = <span />;
132
var instance2 = <span />;
@@ -156,7 +156,7 @@ describe('ReactIdentity', function() {
156
}).not.toThrow();
157
});
158
159
- it('should let nested restructures retain their uniqueness', function() {
159
+ it('should let nested restructures retain their uniqueness', () => {
160
var instance0 = <span />;
161
var instance1 = <span />;
162
var instance2 = <span />;
@@ -190,7 +190,7 @@ describe('ReactIdentity', function() {
190
}).not.toThrow();
191
});
192
193
- it('should let text nodes retain their uniqueness', function() {
193
+ it('should let text nodes retain their uniqueness', () => {
194
class TestComponent extends React.Component {
195
render() {
196
return <div>{this.props.children}<span /></div>;
@@ -215,7 +215,7 @@ describe('ReactIdentity', function() {
215
}).not.toThrow();
216
});
217
218
- it('should retain key during updates in composite components', function() {
218
+ it('should retain key during updates in composite components', () => {
219
class TestComponent extends React.Component {
220
render() {
221
return <div>{this.props.children}</div>;
@@ -257,7 +257,7 @@ describe('ReactIdentity', function() {
257
expect(beforeB).toBe(afterB);
258
});
259
260
- it('should not allow implicit and explicit keys to collide', function() {
260
+ it('should not allow implicit and explicit keys to collide', () => {
261
var component =
262
<div>
263
<span />
src/renderers/shared/stack/reconciler/__tests__/ReactMockedComponent-test.js
+2
-2
@@ -17,9 +17,9 @@ var ReactTestUtils;
17
var AutoMockedComponent;
18
var MockedComponent;
19
20
-describe('ReactMockedComponent', function() {
20
+describe('ReactMockedComponent', () => {
21
22
- beforeEach(function() {
22
+ beforeEach(() => {
23
React = require('React');
24
ReactTestUtils = require('ReactTestUtils');
25
src/renderers/shared/stack/reconciler/__tests__/ReactMultiChild-test.js
+8
-8
@@ -11,7 +11,7 @@
11
12
'use strict';
13
14
-describe('ReactMultiChild', function() {
14
+describe('ReactMultiChild', () => {
15
function normalizeCodeLocInfo(str) {
16
return str.replace(/\(at .+?:\d+\)/g, '(at **)');
17
}
@@ -19,14 +19,14 @@ describe('ReactMultiChild', function() {
19
var React;
20
var ReactDOM;
21
22
- beforeEach(function() {
22
+ beforeEach(() => {
23
jest.resetModuleRegistry();
24
React = require('React');
25
ReactDOM = require('ReactDOM');
26
});
27
28
- describe('reconciliation', function() {
29
- it('should update children when possible', function() {
28
+ describe('reconciliation', () => {
29
+ it('should update children when possible', () => {
30
var container = document.createElement('div');
31
32
var mockMount = jest.fn();
@@ -59,7 +59,7 @@ describe('ReactMultiChild', function() {
59
expect(mockUnmount.mock.calls.length).toBe(0);
60
});
61
62
- it('should replace children with different constructors', function() {
62
+ it('should replace children with different constructors', () => {
63
var container = document.createElement('div');
64
65
var mockMount = jest.fn();
@@ -87,7 +87,7 @@ describe('ReactMultiChild', function() {
87
expect(mockUnmount.mock.calls.length).toBe(1);
88
});
89
90
- it('should NOT replace children with different owners', function() {
90
+ it('should NOT replace children with different owners', () => {
91
var container = document.createElement('div');
92
93
var mockMount = jest.fn();
@@ -124,7 +124,7 @@ describe('ReactMultiChild', function() {
124
expect(mockUnmount.mock.calls.length).toBe(0);
125
});
126
127
- it('should replace children with different keys', function() {
127
+ it('should replace children with different keys', () => {
128
var container = document.createElement('div');
129
130
var mockMount = jest.fn();
@@ -152,7 +152,7 @@ describe('ReactMultiChild', function() {
152
expect(mockUnmount.mock.calls.length).toBe(1);
153
});
154
155
- it('should warn for duplicated keys with component stack info', function() {
155
+ it('should warn for duplicated keys with component stack info', () => {
156
spyOn(console, 'error');
157
158
var container = document.createElement('div');
src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildReconcile-test.js
+29
-29
@@ -275,12 +275,12 @@ function testPropsSequence(sequence) {
275
}
276
}
277
278
-describe('ReactMultiChildReconcile', function() {
279
- beforeEach(function() {
278
+describe('ReactMultiChildReconcile', () => {
279
+ beforeEach(() => {
280
jest.resetModuleRegistry();
281
});
282
283
- it('should reset internal state if removed then readded', function() {
283
+ it('should reset internal state if removed then readded', () => {
284
// Test basics.
285
var props = {
286
usernameToStatus: {
@@ -315,7 +315,7 @@ describe('ReactMultiChildReconcile', function() {
315
.not.toBe(startingInternalState);
316
});
317
318
- it('should create unique identity', function() {
318
+ it('should create unique identity', () => {
319
// Test basics.
320
var usernameToStatus = {
321
jcw: 'jcwStatus',
@@ -326,7 +326,7 @@ describe('ReactMultiChildReconcile', function() {
326
testPropsSequence([{usernameToStatus: usernameToStatus}]);
327
});
328
329
- it('should preserve order if children order has not changed', function() {
329
+ it('should preserve order if children order has not changed', () => {
330
var PROPS_SEQUENCE = [
331
{
332
usernameToStatus: {
@@ -344,7 +344,7 @@ describe('ReactMultiChildReconcile', function() {
344
testPropsSequence(PROPS_SEQUENCE);
345
});
346
347
- it('should transition from zero to one children correctly', function() {
347
+ it('should transition from zero to one children correctly', () => {
348
var PROPS_SEQUENCE = [
349
{usernameToStatus: {} },
350
{
@@ -356,7 +356,7 @@ describe('ReactMultiChildReconcile', function() {
356
testPropsSequence(PROPS_SEQUENCE);
357
});
358
359
- it('should transition from one to zero children correctly', function() {
359
+ it('should transition from one to zero children correctly', () => {
360
var PROPS_SEQUENCE = [
361
{
362
usernameToStatus: {
@@ -368,7 +368,7 @@ describe('ReactMultiChildReconcile', function() {
368
testPropsSequence(PROPS_SEQUENCE);
369
});
370
371
- it('should transition from one child to null children', function() {
371
+ it('should transition from one child to null children', () => {
372
testPropsSequence([
373
{
374
usernameToStatus: {
@@ -379,7 +379,7 @@ describe('ReactMultiChildReconcile', function() {
379
]);
380
});
381
382
- it('should transition from null children to one child', function() {
382
+ it('should transition from null children to one child', () => {
383
testPropsSequence([
384
{},
385
{
@@ -390,7 +390,7 @@ describe('ReactMultiChildReconcile', function() {
390
]);
391
});
392
393
- it('should transition from zero children to null children', function() {
393
+ it('should transition from zero children to null children', () => {
394
testPropsSequence([
395
{
396
usernameToStatus: {},
@@ -399,7 +399,7 @@ describe('ReactMultiChildReconcile', function() {
399
]);
400
});
401
402
- it('should transition from null children to zero children', function() {
402
+ it('should transition from null children to zero children', () => {
403
testPropsSequence([
404
{},
405
{
@@ -414,7 +414,7 @@ describe('ReactMultiChildReconcile', function() {
414
* `FriendsStatusDisplay` renders nulls as empty children (it's a convention
415
* of `FriendsStatusDisplay`, nothing related to React or these test cases.
416
*/
417
- it('should remove nulled out children at the beginning', function() {
417
+ it('should remove nulled out children at the beginning', () => {
418
var PROPS_SEQUENCE = [
419
{
420
usernameToStatus: {
@@ -432,7 +432,7 @@ describe('ReactMultiChildReconcile', function() {
432
testPropsSequence(PROPS_SEQUENCE);
433
});
434
435
- it('should remove nulled out children at the end', function() {
435
+ it('should remove nulled out children at the end', () => {
436
var PROPS_SEQUENCE = [
437
{
438
usernameToStatus: {
@@ -450,7 +450,7 @@ describe('ReactMultiChildReconcile', function() {
450
testPropsSequence(PROPS_SEQUENCE);
451
});
452
453
- it('should reverse the order of two children', function() {
453
+ it('should reverse the order of two children', () => {
454
var PROPS_SEQUENCE = [
455
{
456
usernameToStatus: {
@@ -468,7 +468,7 @@ describe('ReactMultiChildReconcile', function() {
468
testPropsSequence(PROPS_SEQUENCE);
469
});
470
471
- it('should reverse the order of more than two children', function() {
471
+ it('should reverse the order of more than two children', () => {
472
var PROPS_SEQUENCE = [
473
{
474
usernameToStatus: {
@@ -488,7 +488,7 @@ describe('ReactMultiChildReconcile', function() {
488
testPropsSequence(PROPS_SEQUENCE);
489
});
490
491
- it('should cycle order correctly', function() {
491
+ it('should cycle order correctly', () => {
492
var PROPS_SEQUENCE = [
493
{
494
usernameToStatus: {
@@ -534,7 +534,7 @@ describe('ReactMultiChildReconcile', function() {
534
testPropsSequence(PROPS_SEQUENCE);
535
});
536
537
- it('should cycle order correctly in the other direction', function() {
537
+ it('should cycle order correctly in the other direction', () => {
538
var PROPS_SEQUENCE = [
539
{
540
usernameToStatus: {
@@ -581,7 +581,7 @@ describe('ReactMultiChildReconcile', function() {
581
});
582
583
584
- it('should remove nulled out children and ignore new null children', function() {
584
+ it('should remove nulled out children and ignore new null children', () => {
585
var PROPS_SEQUENCE = [
586
{
587
usernameToStatus: {
@@ -600,7 +600,7 @@ describe('ReactMultiChildReconcile', function() {
600
testPropsSequence(PROPS_SEQUENCE);
601
});
602
603
- it('should remove nulled out children and reorder remaining', function() {
603
+ it('should remove nulled out children and reorder remaining', () => {
604
var PROPS_SEQUENCE = [
605
{
606
usernameToStatus: {
@@ -621,7 +621,7 @@ describe('ReactMultiChildReconcile', function() {
621
testPropsSequence(PROPS_SEQUENCE);
622
});
623
624
- it('should append children to the end', function() {
624
+ it('should append children to the end', () => {
625
var PROPS_SEQUENCE = [
626
{
627
usernameToStatus: {
@@ -640,7 +640,7 @@ describe('ReactMultiChildReconcile', function() {
640
testPropsSequence(PROPS_SEQUENCE);
641
});
642
643
- it('should append multiple children to the end', function() {
643
+ it('should append multiple children to the end', () => {
644
var PROPS_SEQUENCE = [
645
{
646
usernameToStatus: {
@@ -660,7 +660,7 @@ describe('ReactMultiChildReconcile', function() {
660
testPropsSequence(PROPS_SEQUENCE);
661
});
662
663
- it('should prepend children to the beginning', function() {
663
+ it('should prepend children to the beginning', () => {
664
var PROPS_SEQUENCE = [
665
{
666
usernameToStatus: {
@@ -679,7 +679,7 @@ describe('ReactMultiChildReconcile', function() {
679
testPropsSequence(PROPS_SEQUENCE);
680
});
681
682
- it('should prepend multiple children to the beginning', function() {
682
+ it('should prepend multiple children to the beginning', () => {
683
var PROPS_SEQUENCE = [
684
{
685
usernameToStatus: {
@@ -699,7 +699,7 @@ describe('ReactMultiChildReconcile', function() {
699
testPropsSequence(PROPS_SEQUENCE);
700
});
701
702
- it('should not prepend an empty child to the beginning', function() {
702
+ it('should not prepend an empty child to the beginning', () => {
703
var PROPS_SEQUENCE = [
704
{
705
usernameToStatus: {
@@ -718,7 +718,7 @@ describe('ReactMultiChildReconcile', function() {
718
testPropsSequence(PROPS_SEQUENCE);
719
});
720
721
- it('should not append an empty child to the end', function() {
721
+ it('should not append an empty child to the end', () => {
722
var PROPS_SEQUENCE = [
723
{
724
usernameToStatus: {
@@ -737,7 +737,7 @@ describe('ReactMultiChildReconcile', function() {
737
testPropsSequence(PROPS_SEQUENCE);
738
});
739
740
- it('should not insert empty children in the middle', function() {
740
+ it('should not insert empty children in the middle', () => {
741
var PROPS_SEQUENCE = [
742
{
743
usernameToStatus: {
@@ -758,7 +758,7 @@ describe('ReactMultiChildReconcile', function() {
758
testPropsSequence(PROPS_SEQUENCE);
759
});
760
761
- it('should insert one new child in the middle', function() {
761
+ it('should insert one new child in the middle', () => {
762
var PROPS_SEQUENCE = [
763
{
764
usernameToStatus: {
@@ -777,7 +777,7 @@ describe('ReactMultiChildReconcile', function() {
777
testPropsSequence(PROPS_SEQUENCE);
778
});
779
780
- it('should insert multiple new truthy children in the middle', function() {
780
+ it('should insert multiple new truthy children in the middle', () => {
781
var PROPS_SEQUENCE = [
782
{
783
usernameToStatus: {
@@ -798,7 +798,7 @@ describe('ReactMultiChildReconcile', function() {
798
testPropsSequence(PROPS_SEQUENCE);
799
});
800
801
- it('should insert non-empty children in middle where nulls were', function() {
801
+ it('should insert non-empty children in middle where nulls were', () => {
802
var PROPS_SEQUENCE = [
803
{
804
usernameToStatus: {
src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildText-test.js
+5
-5
@@ -94,8 +94,8 @@ var expectChildren = function(d, children) {
94
* that single children that are strings are treated as "content" which is much
95
* faster to render and update.
96
*/
97
-describe('ReactMultiChildText', function() {
98
- it('should correctly handle all possible children for render and update', function() {
97
+describe('ReactMultiChildText', () => {
98
+ it('should correctly handle all possible children for render and update', () => {
99
spyOn(console, 'error');
100
testAllPermutations([
101
// basic values
@@ -189,7 +189,7 @@ describe('ReactMultiChildText', function() {
189
);
190
});
191
192
- it('should throw if rendering both HTML and children', function() {
192
+ it('should throw if rendering both HTML and children', () => {
193
expect(function() {
194
ReactTestUtils.renderIntoDocument(
195
<div dangerouslySetInnerHTML={{__html: 'abcdef'}}>ghjkl</div>
@@ -197,7 +197,7 @@ describe('ReactMultiChildText', function() {
197
}).toThrow();
198
});
199
200
- it('should render between nested components and inline children', function() {
200
+ it('should render between nested components and inline children', () => {
201
ReactTestUtils.renderIntoDocument(<div><h1><span /><span /></h1></div>);
202
203
expect(function() {
@@ -213,7 +213,7 @@ describe('ReactMultiChildText', function() {
213
}).not.toThrow();
214
});
215
216
- it('should reorder keyed text nodes', function() {
216
+ it('should reorder keyed text nodes', () => {
217
spyOn(console, 'error');
218
219
var container = document.createElement('div');
src/renderers/shared/stack/reconciler/__tests__/ReactStateSetters-test.js
+8
-8
@@ -18,8 +18,8 @@ var ReactTestUtils = require('ReactTestUtils');
18
var TestComponent;
19
var TestComponentWithMixin;
20
21
-describe('ReactStateSetters', function() {
22
- beforeEach(function() {
21
+describe('ReactStateSetters', () => {
22
+ beforeEach(() => {
23
jest.resetModuleRegistry();
24
25
TestComponent = class extends React.Component {
@@ -43,7 +43,7 @@ describe('ReactStateSetters', function() {
43
});
44
});
45
46
- it('createStateSetter should update state', function() {
46
+ it('createStateSetter should update state', () => {
47
var instance = <TestComponent />;
48
instance = ReactTestUtils.renderIntoDocument(instance);
49
expect(instance.state).toEqual({foo: 'foo'});
@@ -66,7 +66,7 @@ describe('ReactStateSetters', function() {
66
expect(instance.state).toEqual({foo: 33, bar: 1320});
67
});
68
69
- it('createStateKeySetter should update state', function() {
69
+ it('createStateKeySetter should update state', () => {
70
var instance = <TestComponent />;
71
instance = ReactTestUtils.renderIntoDocument(instance);
72
expect(instance.state).toEqual({foo: 'foo'});
@@ -82,7 +82,7 @@ describe('ReactStateSetters', function() {
82
expect(instance.state).toEqual({foo: 'baz'});
83
});
84
85
- it('createStateKeySetter is memoized', function() {
85
+ it('createStateKeySetter is memoized', () => {
86
var instance = <TestComponent />;
87
instance = ReactTestUtils.renderIntoDocument(instance);
88
expect(instance.state).toEqual({foo: 'foo'});
@@ -97,7 +97,7 @@ describe('ReactStateSetters', function() {
97
expect(bar2).toBe(bar1);
98
});
99
100
- it('createStateSetter should update state from mixin', function() {
100
+ it('createStateSetter should update state from mixin', () => {
101
var instance = <TestComponentWithMixin />;
102
instance = ReactTestUtils.renderIntoDocument(instance);
103
expect(instance.state).toEqual({foo: 'foo'});
@@ -119,7 +119,7 @@ describe('ReactStateSetters', function() {
119
expect(instance.state).toEqual({foo: 33, bar: 1320});
120
});
121
122
- it('createStateKeySetter should update state with mixin', function() {
122
+ it('createStateKeySetter should update state with mixin', () => {
123
var instance = <TestComponentWithMixin />;
124
instance = ReactTestUtils.renderIntoDocument(instance);
125
expect(instance.state).toEqual({foo: 'foo'});
@@ -135,7 +135,7 @@ describe('ReactStateSetters', function() {
135
expect(instance.state).toEqual({foo: 'baz'});
136
});
137
138
- it('createStateKeySetter is memoized with mixin', function() {
138
+ it('createStateKeySetter is memoized with mixin', () => {
139
var instance = <TestComponentWithMixin />;
140
instance = ReactTestUtils.renderIntoDocument(instance);
141
expect(instance.state).toEqual({foo: 'foo'});
src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js
+17
-17
@@ -19,22 +19,22 @@ function StatelessComponent(props) {
19
return <div>{props.name}</div>;
20
}
21
22
-describe('ReactStatelessComponent', function() {
22
+describe('ReactStatelessComponent', () => {
23
24
- beforeEach(function() {
24
+ beforeEach(() => {
25
React = require('React');
26
ReactDOM = require('ReactDOM');
27
ReactTestUtils = require('ReactTestUtils');
28
});
29
30
- it('should render stateless component', function() {
30
+ it('should render stateless component', () => {
31
var el = document.createElement('div');
32
ReactDOM.render(<StatelessComponent name="A" />, el);
33
34
expect(el.textContent).toBe('A');
35
});
36
37
- it('should update stateless component', function() {
37
+ it('should update stateless component', () => {
38
class Parent extends React.Component {
39
render() {
40
return <StatelessComponent {...this.props} />;
@@ -49,7 +49,7 @@ describe('ReactStatelessComponent', function() {
49
expect(el.textContent).toBe('B');
50
});
51
52
- it('should unmount stateless component', function() {
52
+ it('should unmount stateless component', () => {
53
var container = document.createElement('div');
54
55
ReactDOM.render(<StatelessComponent name="A" />, container);
@@ -59,7 +59,7 @@ describe('ReactStatelessComponent', function() {
59
expect(container.textContent).toBe('');
60
});
61
62
- it('should pass context thru stateless component', function() {
62
+ it('should pass context thru stateless component', () => {
63
class Child extends React.Component {
64
static contextTypes = {
65
test: React.PropTypes.string.isRequired,
@@ -119,7 +119,7 @@ describe('ReactStatelessComponent', function() {
119
);
120
});
121
122
- it('should warn when stateless component returns array', function() {
122
+ it('should warn when stateless component returns array', () => {
123
spyOn(console, 'error');
124
function NotAComponent() {
125
return [<div />, <div />];
@@ -134,7 +134,7 @@ describe('ReactStatelessComponent', function() {
134
);
135
});
136
137
- it('should throw on string refs in pure functions', function() {
137
+ it('should throw on string refs in pure functions', () => {
138
function Child() {
139
return <div ref="me" />;
140
}
@@ -146,7 +146,7 @@ describe('ReactStatelessComponent', function() {
146
);
147
});
148
149
- it('should warn when given a ref', function() {
149
+ it('should warn when given a ref', () => {
150
spyOn(console, 'error');
151
152
class Parent extends React.Component {
@@ -167,7 +167,7 @@ describe('ReactStatelessComponent', function() {
167
);
168
});
169
170
- it('should provide a null ref', function() {
170
+ it('should provide a null ref', () => {
171
function Child() {
172
return <div />;
173
}
@@ -176,7 +176,7 @@ describe('ReactStatelessComponent', function() {
176
expect(comp).toBe(null);
177
});
178
179
- it('should use correct name in key warning', function() {
179
+ it('should use correct name in key warning', () => {
180
function Child() {
181
return <div>{[<span />]}</div>;
182
}
@@ -188,7 +188,7 @@ describe('ReactStatelessComponent', function() {
188
expect(console.error.calls.argsFor(0)[0]).toContain('Child');
189
});
190
191
- it('should support default props and prop types', function() {
191
+ it('should support default props and prop types', () => {
192
function Child(props) {
193
return <div>{props.test}</div>;
194
}
@@ -207,7 +207,7 @@ describe('ReactStatelessComponent', function() {
207
);
208
});
209
210
- it('should receive context', function() {
210
+ it('should receive context', () => {
211
class Parent extends React.Component {
212
static childContextTypes = {
213
lang: React.PropTypes.string,
@@ -232,7 +232,7 @@ describe('ReactStatelessComponent', function() {
232
expect(el.textContent).toBe('en');
233
});
234
235
- it('should work with arrow functions', function() {
235
+ it('should work with arrow functions', () => {
236
var Child = function() {
237
return <div />;
238
};
@@ -243,21 +243,21 @@ describe('ReactStatelessComponent', function() {
243
expect(() => ReactTestUtils.renderIntoDocument(<Child />)).not.toThrow();
244
});
245
246
- it('should allow simple functions to return null', function() {
246
+ it('should allow simple functions to return null', () => {
247
var Child = function() {
248
return null;
249
};
250
expect(() => ReactTestUtils.renderIntoDocument(<Child />)).not.toThrow();
251
});
252
253
- it('should allow simple functions to return false', function() {
253
+ it('should allow simple functions to return false', () => {
254
function Child() {
255
return false;
256
}
257
expect(() => ReactTestUtils.renderIntoDocument(<Child />)).not.toThrow();
258
});
259
260
- it('should warn when using non-React functions in JSX', function() {
260
+ it('should warn when using non-React functions in JSX', () => {
261
spyOn(console, 'error');
262
function NotAComponent() {
263
return [<div />, <div />];
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
+29
-29
@@ -16,15 +16,15 @@ var ReactDOM;
16
var ReactTestUtils;
17
var ReactUpdates;
18
19
-describe('ReactUpdates', function() {
20
- beforeEach(function() {
19
+describe('ReactUpdates', () => {
20
+ beforeEach(() => {
21
React = require('React');
22
ReactDOM = require('ReactDOM');
23
ReactTestUtils = require('ReactTestUtils');
24
ReactUpdates = require('ReactUpdates');
25
});
26
27
- it('should batch state when updating state twice', function() {
27
+ it('should batch state when updating state twice', () => {
28
var updateCount = 0;
29
30
class Component extends React.Component {
@@ -53,7 +53,7 @@ describe('ReactUpdates', function() {
53
expect(updateCount).toBe(1);
54
});
55
56
- it('should batch state when updating two different state keys', function() {
56
+ it('should batch state when updating two different state keys', () => {
57
var updateCount = 0;
58
59
class Component extends React.Component {
@@ -85,7 +85,7 @@ describe('ReactUpdates', function() {
85
expect(updateCount).toBe(1);
86
});
87
88
- it('should batch state and props together', function() {
88
+ it('should batch state and props together', () => {
89
var updateCount = 0;
90
91
class Component extends React.Component {
@@ -118,7 +118,7 @@ describe('ReactUpdates', function() {
118
expect(updateCount).toBe(1);
119
});
120
121
- it('should batch parent/child state updates together', function() {
121
+ it('should batch parent/child state updates together', () => {
122
var parentUpdateCount = 0;
123
124
class Parent extends React.Component {
@@ -167,7 +167,7 @@ describe('ReactUpdates', function() {
167
expect(childUpdateCount).toBe(1);
168
});
169
170
- it('should batch child/parent state updates together', function() {
170
+ it('should batch child/parent state updates together', () => {
171
var parentUpdateCount = 0;
172
173
class Parent extends React.Component {
@@ -218,7 +218,7 @@ describe('ReactUpdates', function() {
218
expect(childUpdateCount).toBe(1);
219
});
220
221
- it('should support chained state updates', function() {
221
+ it('should support chained state updates', () => {
222
var updateCount = 0;
223
224
class Component extends React.Component {
@@ -257,7 +257,7 @@ describe('ReactUpdates', function() {
257
expect(updateCount).toBe(2);
258
});
259
260
- it('should batch forceUpdate together', function() {
260
+ it('should batch forceUpdate together', () => {
261
var shouldUpdateCount = 0;
262
var updateCount = 0;
263
@@ -299,7 +299,7 @@ describe('ReactUpdates', function() {
299
expect(updateCount).toBe(1);
300
});
301
302
- it('should update children even if parent blocks updates', function() {
302
+ it('should update children even if parent blocks updates', () => {
303
var parentRenderCount = 0;
304
var childRenderCount = 0;
305
@@ -345,7 +345,7 @@ describe('ReactUpdates', function() {
345
expect(childRenderCount).toBe(2);
346
});
347
348
- it('should not reconcile children passed via props', function() {
348
+ it('should not reconcile children passed via props', () => {
349
var numMiddleRenders = 0;
350
var numBottomRenders = 0;
351
@@ -378,7 +378,7 @@ describe('ReactUpdates', function() {
378
expect(numBottomRenders).toBe(1);
379
});
380
381
- it('should flow updates correctly', function() {
381
+ it('should flow updates correctly', () => {
382
var willUpdates = [];
383
var didUpdates = [];
384
@@ -505,7 +505,7 @@ describe('ReactUpdates', function() {
505
);
506
});
507
508
- it('should share reconcile transaction across different roots', function() {
508
+ it('should share reconcile transaction across different roots', () => {
509
var ReconcileTransaction = ReactUpdates.ReactReconcileTransaction;
510
spyOn(ReconcileTransaction, 'getPooled').and.callThrough();
511
@@ -534,7 +534,7 @@ describe('ReactUpdates', function() {
534
expect(ReconcileTransaction.getPooled.calls.count()).toBe(3);
535
});
536
537
- it('should queue mount-ready handlers across different roots', function() {
537
+ it('should queue mount-ready handlers across different roots', () => {
538
// We'll define two components A and B, then update both of them. When A's
539
// componentDidUpdate handlers is called, B's DOM should already have been
540
// updated.
@@ -576,7 +576,7 @@ describe('ReactUpdates', function() {
576
expect(aUpdated).toBe(true);
577
});
578
579
- it('should flush updates in the correct order', function() {
579
+ it('should flush updates in the correct order', () => {
580
var updates = [];
581
582
class Outer extends React.Component {
@@ -651,7 +651,7 @@ describe('ReactUpdates', function() {
651
/* eslint-enable indent */
652
});
653
654
- it('should flush updates in the correct order across roots', function() {
654
+ it('should flush updates in the correct order across roots', () => {
655
var instances = [];
656
var updates = [];
657
@@ -689,7 +689,7 @@ describe('ReactUpdates', function() {
689
expect(updates).toEqual([0, 1, 2, 0, 1, 2]);
690
});
691
692
- it('should queue nested updates', function() {
692
+ it('should queue nested updates', () => {
693
// See https://github.com/facebook/react/issues/1147
694
695
class X extends React.Component {
@@ -745,7 +745,7 @@ describe('ReactUpdates', function() {
745
expect(ReactDOM.findDOMNode(x).textContent).toBe('1');
746
});
747
748
- it('should queue updates from during mount', function() {
748
+ it('should queue updates from during mount', () => {
749
// See https://github.com/facebook/react/issues/1353
750
var a;
751
@@ -784,7 +784,7 @@ describe('ReactUpdates', function() {
784
expect(ReactDOM.findDOMNode(a).textContent).toBe('A1');
785
});
786
787
- it('calls componentWillReceiveProps setState callback properly', function() {
787
+ it('calls componentWillReceiveProps setState callback properly', () => {
788
var callbackCount = 0;
789
790
class A extends React.Component {
@@ -810,7 +810,7 @@ describe('ReactUpdates', function() {
810
expect(callbackCount).toBe(1);
811
});
812
813
- it('calls asap callbacks properly', function() {
813
+ it('calls asap callbacks properly', () => {
814
var callbackCount = 0;
815
816
class A extends React.Component {
@@ -836,7 +836,7 @@ describe('ReactUpdates', function() {
836
expect(callbackCount).toBe(2);
837
});
838
839
- it('calls asap callbacks with queued updates', function() {
839
+ it('calls asap callbacks with queued updates', () => {
840
var log = [];
841
842
class A extends React.Component {
@@ -887,7 +887,7 @@ describe('ReactUpdates', function() {
887
]);
888
});
889
890
- it('does not call render after a component as been deleted', function() {
890
+ it('does not call render after a component as been deleted', () => {
891
var renderCount = 0;
892
var componentB = null;
893
@@ -924,7 +924,7 @@ describe('ReactUpdates', function() {
924
expect(renderCount).toBe(1);
925
});
926
927
- it('marks top-level updates', function() {
927
+ it('marks top-level updates', () => {
928
var ReactFeatureFlags = require('ReactFeatureFlags');
929
930
class Foo extends React.Component {
@@ -958,7 +958,7 @@ describe('ReactUpdates', function() {
958
}
959
});
960
961
- it('throws in setState if the update callback is not a function', function() {
961
+ it('throws in setState if the update callback is not a function', () => {
962
function Foo() {
963
this.a = 1;
964
this.b = 2;
@@ -988,7 +988,7 @@ describe('ReactUpdates', function() {
988
);
989
});
990
991
- it('throws in replaceState if the update callback is not a function', function() {
991
+ it('throws in replaceState if the update callback is not a function', () => {
992
function Foo() {
993
this.a = 1;
994
this.b = 2;
@@ -1017,7 +1017,7 @@ describe('ReactUpdates', function() {
1017
);
1018
});
1019
1020
- it('throws in forceUpdate if the update callback is not a function', function() {
1020
+ it('throws in forceUpdate if the update callback is not a function', () => {
1021
function Foo() {
1022
this.a = 1;
1023
this.b = 2;
@@ -1047,7 +1047,7 @@ describe('ReactUpdates', function() {
1047
);
1048
});
1049
1050
- it('does not update one component twice in a batch (#2410)', function() {
1050
+ it('does not update one component twice in a batch (#2410)', () => {
1051
class Parent extends React.Component {
1052
getChild = () => {
1053
return this.refs.child;
@@ -1097,7 +1097,7 @@ describe('ReactUpdates', function() {
1097
});
1098
});
1099
1100
- it('does not update one component twice in a batch (#6371)', function() {
1100
+ it('does not update one component twice in a batch (#6371)', () => {
1101
var callbacks = [];
1102
function emitChange() {
1103
callbacks.forEach(c => c());
@@ -1147,7 +1147,7 @@ describe('ReactUpdates', function() {
1147
ReactDOM.render(<App />, document.createElement('div'));
1148
});
1149
1150
- it('unstable_batchedUpdates should return value from a callback', function() {
1150
+ it('unstable_batchedUpdates should return value from a callback', () => {
1151
var result = ReactDOM.unstable_batchedUpdates(function() {
1152
return 42;
1153
});
src/renderers/shared/stack/reconciler/__tests__/refs-destruction-test.js
+5
-5
@@ -17,8 +17,8 @@ var ReactTestUtils;
17
18
var TestComponent;
19
20
-describe('refs-destruction', function() {
21
- beforeEach(function() {
20
+describe('refs-destruction', () => {
21
+ beforeEach(() => {
22
jest.resetModuleRegistry();
23
24
React = require('React');
@@ -40,7 +40,7 @@ describe('refs-destruction', function() {
40
};
41
});
42
43
- it('should remove refs when destroying the parent', function() {
43
+ it('should remove refs when destroying the parent', () => {
44
var container = document.createElement('div');
45
var testInstance = ReactDOM.render(<TestComponent />, container);
46
expect(ReactTestUtils.isDOMComponent(testInstance.refs.theInnerDiv))
@@ -50,7 +50,7 @@ describe('refs-destruction', function() {
50
expect(Object.keys(testInstance.refs || {}).length).toEqual(0);
51
});
52
53
- it('should remove refs when destroying the child', function() {
53
+ it('should remove refs when destroying the child', () => {
54
var container = document.createElement('div');
55
var testInstance = ReactDOM.render(<TestComponent />, container);
56
expect(ReactTestUtils.isDOMComponent(testInstance.refs.theInnerDiv))
@@ -60,7 +60,7 @@ describe('refs-destruction', function() {
60
expect(Object.keys(testInstance.refs || {}).length).toEqual(0);
61
});
62
63
- it('should not error when destroying child with ref asynchronously', function() {
63
+ it('should not error when destroying child with ref asynchronously', () => {
64
class Modal extends React.Component {
65
componentDidMount() {
66
this.div = document.createElement('div');
src/renderers/shared/stack/reconciler/__tests__/refs-test.js
+9
-9
@@ -115,8 +115,8 @@ var expectClickLogsLengthToBe = function(instance, length) {
115
expect(Object.keys(instance.refs.myCounter.refs).length).toBe(length);
116
};
117
118
-describe('reactiverefs', function() {
119
- beforeEach(function() {
118
+describe('reactiverefs', () => {
119
+ beforeEach(() => {
120
jest.resetModuleRegistry();
121
});
122
@@ -124,7 +124,7 @@ describe('reactiverefs', function() {
124
* Ensure that for every click log there is a corresponding ref (from the
125
* perspective of the injected ClickCounter component.
126
*/
127
- it('Should increase refs with an increase in divs', function() {
127
+ it('Should increase refs with an increase in divs', () => {
128
var testRefsComponent = renderTestRefsComponent();
129
var clickIncrementer =
130
ReactTestUtils.findRenderedDOMComponentWithClass(
@@ -158,8 +158,8 @@ describe('reactiverefs', function() {
158
/**
159
* Tests that when a ref hops around children, we can track that correctly.
160
*/
161
-describe('ref swapping', function() {
162
- beforeEach(function() {
161
+describe('ref swapping', () => {
162
+ beforeEach(() => {
163
jest.resetModuleRegistry();
164
});
165
@@ -197,7 +197,7 @@ describe('ref swapping', function() {
197
}
198
}
199
200
- it('Allow refs to hop around children correctly', function() {
200
+ it('Allow refs to hop around children correctly', () => {
201
var refHopsAround = ReactTestUtils.renderIntoDocument(<RefHopsAround />);
202
203
var firstDiv =
@@ -232,7 +232,7 @@ describe('ref swapping', function() {
232
});
233
234
235
- it('always has a value for this.refs', function() {
235
+ it('always has a value for this.refs', () => {
236
class Component extends React.Component {
237
render() {
238
return <div />;
@@ -267,14 +267,14 @@ describe('ref swapping', function() {
267
expect(refCalled).toBe(1);
268
}
269
270
- it('ref called correctly for stateless component when __DEV__ = false', function() {
270
+ it('ref called correctly for stateless component when __DEV__ = false', () => {
271
var originalDev = __DEV__;
272
__DEV__ = false;
273
testRefCall();
274
__DEV__ = originalDev;
275
});
276
277
- it('ref called correctly for stateless component when __DEV__ = true', function() {
277
+ it('ref called correctly for stateless component when __DEV__ = true', () => {
278
var originalDev = __DEV__;
279
__DEV__ = true;
280
testRefCall();
src/renderers/shared/utils/__tests__/Transaction-test.js
+7
-7
@@ -15,8 +15,8 @@
15
var Transaction;
16
17
var INIT_ERRORED = 'initErrored'; // Just a dummy value to check for.
18
-describe('Transaction', function() {
19
- beforeEach(function() {
18
+describe('Transaction', () => {
19
+ beforeEach(() => {
20
jest.resetModuleRegistry();
21
Transaction = require('Transaction');
22
});
@@ -26,7 +26,7 @@ describe('Transaction', function() {
26
* return values to closers when those inits are successful. We should not
27
* invoke the actual method when any of the initializers fail.
28
*/
29
- it('should invoke closers with/only-with init returns', function() {
29
+ it('should invoke closers with/only-with init returns', () => {
30
var throwInInit = function() {
31
throw new Error('close[0] should receive Transaction.OBSERVED_ERROR');
32
};
@@ -84,7 +84,7 @@ describe('Transaction', function() {
84
expect(transaction.isInTransaction()).toBe(false);
85
});
86
87
- it('should invoke closers and wrapped method when inits success', function() {
87
+ it('should invoke closers and wrapped method when inits success', () => {
88
89
var performSideEffect;
90
/**
@@ -145,7 +145,7 @@ describe('Transaction', function() {
145
* throws an error, the transaction should prefer to throw the error
146
* encountered earlier in the operation.
147
*/
148
- it('should throw when wrapped operation throws', function() {
148
+ it('should throw when wrapped operation throws', () => {
149
150
var performSideEffect;
151
/**
@@ -217,7 +217,7 @@ describe('Transaction', function() {
217
expect(transaction.isInTransaction()).toBe(false);
218
});
219
220
- it('should throw errors in transaction close', function() {
220
+ it('should throw errors in transaction close', () => {
221
var TestTransaction = function() {
222
this.reinitializeTransaction();
223
};
@@ -240,7 +240,7 @@ describe('Transaction', function() {
240
expect(transaction.isInTransaction()).toBe(false);
241
});
242
243
- it('should allow nesting of transactions', function() {
243
+ it('should allow nesting of transactions', () => {
244
var performSideEffect;
245
var nestedPerformSideEffect;
246
/**
src/renderers/shared/utils/__tests__/accumulateInto-test.js
+6
-6
@@ -13,13 +13,13 @@
13
14
var accumulateInto;
15
16
-describe('accumulateInto', function() {
16
+describe('accumulateInto', () => {
17
18
- beforeEach(function() {
18
+ beforeEach(() => {
19
accumulateInto = require('accumulateInto');
20
});
21
22
- it('throws if the second item is null', function() {
22
+ it('throws if the second item is null', () => {
23
expect(function() {
24
accumulateInto([], null);
25
}).toThrowError(
@@ -27,12 +27,12 @@ describe('accumulateInto', function() {
27
);
28
});
29
30
- it('returns the second item if first is null', function() {
30
+ it('returns the second item if first is null', () => {
31
var a = [];
32
expect(accumulateInto(null, a)).toBe(a);
33
});
34
35
- it('merges the second into the first if first item is an array', function() {
35
+ it('merges the second into the first if first item is an array', () => {
36
var a = [1, 2];
37
var b = [3, 4];
38
accumulateInto(a, b);
@@ -43,7 +43,7 @@ describe('accumulateInto', function() {
43
expect(c).toEqual([1, 2]);
44
});
45
46
- it('returns a new array if first or both items are scalar', function() {
46
+ it('returns a new array if first or both items are scalar', () => {
47
var a = [2];
48
expect(accumulateInto(1, a)).toEqual([1, 2]);
49
expect(a).toEqual([2]);
src/renderers/shared/utils/__tests__/adler32-test.js
+6
-6
@@ -13,20 +13,20 @@
13
14
var adler32 = require('adler32');
15
16
-describe('adler32', function() {
17
- it('generates differing checksums', function() {
16
+describe('adler32', () => {
17
+ it('generates differing checksums', () => {
18
expect(adler32('foo')).not.toBe(adler32('bar'));
19
});
20
21
- it('generates consistent checksums', function() {
21
+ it('generates consistent checksums', () => {
22
expect(adler32('linux')).toBe(adler32('linux'));
23
});
24
25
- it('is case sensitive', function() {
25
+ it('is case sensitive', () => {
26
expect(adler32('a')).not.toBe(adler32('A'));
27
});
28
29
- it('doesn\'t barf on large inputs', function() {
29
+ it('doesn\'t barf on large inputs', () => {
30
var str = '';
31
for (var i = 0; i < 100000; i++) {
32
str += 'This will be repeated to be very large indeed. ';
@@ -34,7 +34,7 @@ describe('adler32', function() {
34
expect(adler32(str)).toBe(692898118);
35
});
36
37
- it('doesn\'t barf on international inputs', function() {
37
+ it('doesn\'t barf on international inputs', () => {
38
var str = 'Linux 是一個真棒操作系統!';
39
expect(adler32(str)).toBe(-1183804097);
40
});
src/renderers/testing/__tests__/ReactTestRenderer-test.js
+12
-12
@@ -14,9 +14,9 @@
14
var React = require('React');
15
var ReactTestRenderer = require('ReactTestRenderer');
16
17
-describe('ReactTestRenderer', function() {
17
+describe('ReactTestRenderer', () => {
18
19
- it('renders a simple component', function() {
19
+ it('renders a simple component', () => {
20
function Link() {
21
return <a role="link" />;
22
}
@@ -28,7 +28,7 @@ describe('ReactTestRenderer', function() {
28
});
29
});
30
31
- it('renders a top-level empty component', function() {
31
+ it('renders a top-level empty component', () => {
32
function Empty() {
33
return null;
34
}
@@ -36,7 +36,7 @@ describe('ReactTestRenderer', function() {
36
expect(renderer.toJSON()).toEqual(null);
37
});
38
39
- it('exposes a type flag', function() {
39
+ it('exposes a type flag', () => {
40
function Link() {
41
return <a role="link" />;
42
}
@@ -52,7 +52,7 @@ describe('ReactTestRenderer', function() {
52
}
53
});
54
55
- it('renders some basics with an update', function() {
55
+ it('renders some basics with an update', () => {
56
var renders = 0;
57
58
class Component extends React.Component {
@@ -89,7 +89,7 @@ describe('ReactTestRenderer', function() {
89
expect(renders).toBe(6);
90
});
91
92
- it('exposes the instance', function() {
92
+ it('exposes the instance', () => {
93
class Mouse extends React.Component {
94
constructor() {
95
super();
@@ -119,7 +119,7 @@ describe('ReactTestRenderer', function() {
119
});
120
});
121
122
- it('updates types', function() {
122
+ it('updates types', () => {
123
var renderer = ReactTestRenderer.create(<div>mouse</div>);
124
expect(renderer.toJSON()).toEqual({
125
type: 'div',
@@ -135,7 +135,7 @@ describe('ReactTestRenderer', function() {
135
});
136
});
137
138
- it('updates children', function() {
138
+ it('updates children', () => {
139
var renderer = ReactTestRenderer.create(
140
<div>
141
<span key="a">A</span>
@@ -171,7 +171,7 @@ describe('ReactTestRenderer', function() {
171
});
172
});
173
174
- it('does the full lifecycle', function() {
174
+ it('does the full lifecycle', () => {
175
var log = [];
176
class Log extends React.Component {
177
render() {
@@ -200,13 +200,13 @@ describe('ReactTestRenderer', function() {
200
]);
201
});
202
203
- it('gives a ref to native components', function() {
203
+ it('gives a ref to native components', () => {
204
var log = [];
205
ReactTestRenderer.create(<div ref={(r) => log.push(r)} />);
206
expect(log).toEqual([null]);
207
});
208
209
- it('warns correctly for refs on SFCs', function() {
209
+ it('warns correctly for refs on SFCs', () => {
210
spyOn(console, 'error');
211
function Bar() {
212
return <div>Hello, world</div>
@@ -231,7 +231,7 @@ describe('ReactTestRenderer', function() {
231
);
232
});
233
234
- it('supports error boundaries', function() {
234
+ it('supports error boundaries', () => {
235
var log = [];
236
class Angry extends React.Component {
237
render() {
src/shared/utils/__tests__/PooledClass-test.js
+12
-12
@@ -14,25 +14,25 @@
14
var PooledClass;
15
var PoolableClass;
16
17
-describe('Pooled class', function() {
18
- beforeEach(function() {
17
+describe('Pooled class', () => {
18
+ beforeEach(() => {
19
PooledClass = require('PooledClass');
20
PoolableClass = function() {};
21
PoolableClass.prototype.destructor = function() {};
22
PooledClass.addPoolingTo(PoolableClass);
23
});
24
25
- it('should initialize a pool correctly', function() {
25
+ it('should initialize a pool correctly', () => {
26
expect(PoolableClass.instancePool).toBeDefined();
27
});
28
29
- it('should return a new instance when the pool is empty', function() {
29
+ it('should return a new instance when the pool is empty', () => {
30
var instance = PoolableClass.getPooled();
31
expect(instance instanceof PoolableClass).toBe(true);
32
});
33
34
it('should return the instance back into the pool when it gets released',
35
- function() {
35
+ () => {
36
var instance = PoolableClass.getPooled();
37
PoolableClass.release(instance);
38
expect(PoolableClass.instancePool.length).toBe(1);
@@ -40,14 +40,14 @@ describe('Pooled class', function() {
40
}
41
);
42
43
- it('should return an old instance if available in the pool', function() {
43
+ it('should return an old instance if available in the pool', () => {
44
var instance = PoolableClass.getPooled();
45
PoolableClass.release(instance);
46
var instance2 = PoolableClass.getPooled();
47
expect(instance).toBe(instance2);
48
});
49
50
- it('should call the destructor when instance gets released', function() {
50
+ it('should call the destructor when instance gets released', () => {
51
var log = [];
52
var PoolableClassWithDestructor = function() {};
53
PoolableClassWithDestructor.prototype.destructor = function() {
@@ -59,7 +59,7 @@ describe('Pooled class', function() {
59
expect(log).toEqual(['released']);
60
});
61
62
- it('should accept poolers with different arguments', function() {
62
+ it('should accept poolers with different arguments', () => {
63
var log = [];
64
var PoolableClassWithMultiArguments = function(a, b) {
65
log.push(a, b);
@@ -73,7 +73,7 @@ describe('Pooled class', function() {
73
expect(log).toEqual(['a', 'b']);
74
});
75
76
- it('should call a new constructor with arguments', function() {
76
+ it('should call a new constructor with arguments', () => {
77
var log = [];
78
var PoolableClassWithOneArgument = function(a) {
79
log.push(a);
@@ -86,7 +86,7 @@ describe('Pooled class', function() {
86
expect(log).toEqual(['new']);
87
});
88
89
- it('should call an old constructor with arguments', function() {
89
+ it('should call an old constructor with arguments', () => {
90
var log = [];
91
var PoolableClassWithOneArgument = function(a) {
92
log.push(a);
@@ -102,7 +102,7 @@ describe('Pooled class', function() {
102
});
103
104
it('should throw when the class releases an instance of a different type',
105
- function() {
105
+ () => {
106
var RandomClass = function() {};
107
RandomClass.prototype.destructor = function() {};
108
PooledClass.addPoolingTo(RandomClass);
@@ -116,7 +116,7 @@ describe('Pooled class', function() {
116
}
117
);
118
119
- it('should throw if no destructor is defined', function() {
119
+ it('should throw if no destructor is defined', () => {
120
var ImmortalClass = function() {};
121
PooledClass.addPoolingTo(ImmortalClass);
122
var inst = ImmortalClass.getPooled();
src/shared/utils/__tests__/reactProdInvariant-test.js
+3
-3
@@ -12,13 +12,13 @@
12
13
var reactProdInvariant;
14
15
-describe('reactProdInvariant', function() {
16
- beforeEach(function() {
15
+describe('reactProdInvariant', () => {
16
+ beforeEach(() => {
17
jest.resetModuleRegistry();
18
reactProdInvariant = require('reactProdInvariant');
19
});
20
21
- it('should throw with the correct number of `%s`s in the URL', function() {
21
+ it('should throw with the correct number of `%s`s in the URL', () => {
22
expect(function() {
23
reactProdInvariant(124, 'foo', 'bar');
24
}).toThrowError(
src/shared/utils/__tests__/traverseAllChildren-test.js
+17
-17
@@ -11,13 +11,13 @@
11
12
'use strict';
13
14
-describe('traverseAllChildren', function() {
14
+describe('traverseAllChildren', () => {
15
var traverseAllChildren;
16
var React;
17
var ReactFragment;
18
var ReactTestUtils;
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
jest.resetModuleRegistry();
22
traverseAllChildren = require('traverseAllChildren');
23
React = require('React');
@@ -29,7 +29,7 @@ describe('traverseAllChildren', function() {
29
return ReactFragment.create(obj);
30
}
31
32
- it('should support identity for simple', function() {
32
+ it('should support identity for simple', () => {
33
var traverseContext = [];
34
var traverseFn =
35
jasmine.createSpy().and.callFake(function(context, kid, key, index) {
@@ -49,7 +49,7 @@ describe('traverseAllChildren', function() {
49
expect(traverseContext.length).toEqual(1);
50
});
51
52
- it('should treat single arrayless child as being in array', function() {
52
+ it('should treat single arrayless child as being in array', () => {
53
var traverseContext = [];
54
var traverseFn =
55
jasmine.createSpy().and.callFake(function(context, kid, key, index) {
@@ -67,7 +67,7 @@ describe('traverseAllChildren', function() {
67
expect(traverseContext.length).toEqual(1);
68
});
69
70
- it('should treat single child in array as expected', function() {
70
+ it('should treat single child in array as expected', () => {
71
spyOn(console, 'error');
72
var traverseContext = [];
73
var traverseFn =
@@ -90,7 +90,7 @@ describe('traverseAllChildren', function() {
90
);
91
});
92
93
- it('should be called for each child', function() {
93
+ it('should be called for each child', () => {
94
var zero = <div key="keyZero" />;
95
var one = null;
96
var two = <div key="keyTwo" />;
@@ -133,7 +133,7 @@ describe('traverseAllChildren', function() {
133
);
134
});
135
136
- it('should traverse children of different kinds', function() {
136
+ it('should traverse children of different kinds', () => {
137
var div = <div key="divNode" />;
138
var span = <span key="spanNode" />;
139
var a = <a key="aNode" />;
@@ -192,7 +192,7 @@ describe('traverseAllChildren', function() {
192
);
193
});
194
195
- it('should be called for each child in nested structure', function() {
195
+ it('should be called for each child in nested structure', () => {
196
var zero = <div key="keyZero" />;
197
var one = null;
198
var two = <div key="keyTwo" />;
@@ -252,7 +252,7 @@ describe('traverseAllChildren', function() {
252
);
253
});
254
255
- it('should retain key across two mappings', function() {
255
+ it('should retain key across two mappings', () => {
256
var zeroForceKey = <div key="keyZero" />;
257
var oneForceKey = <div key="keyOne" />;
258
var traverseContext = [];
@@ -282,7 +282,7 @@ describe('traverseAllChildren', function() {
282
);
283
});
284
285
- it('should be called for each child in an iterable without keys', function() {
285
+ it('should be called for each child in an iterable without keys', () => {
286
spyOn(console, 'error');
287
var threeDivIterable = {
288
'@@iterator': function() {
@@ -336,7 +336,7 @@ describe('traverseAllChildren', function() {
336
);
337
});
338
339
- it('should be called for each child in an iterable with keys', function() {
339
+ it('should be called for each child in an iterable with keys', () => {
340
var threeDivIterable = {
341
'@@iterator': function() {
342
var i = 0;
@@ -384,7 +384,7 @@ describe('traverseAllChildren', function() {
384
);
385
});
386
387
- it('should use keys from entry iterables', function() {
387
+ it('should use keys from entry iterables', () => {
388
spyOn(console, 'error');
389
390
var threeDivEntryIterable = {
@@ -442,7 +442,7 @@ describe('traverseAllChildren', function() {
442
);
443
});
444
445
- it('should not enumerate enumerable numbers (#4776)', function() {
445
+ it('should not enumerate enumerable numbers (#4776)', () => {
446
/*eslint-disable no-extend-native */
447
Number.prototype['@@iterator'] = function() {
448
throw new Error('number iterator called');
@@ -483,7 +483,7 @@ describe('traverseAllChildren', function() {
483
}
484
});
485
486
- it('should allow extension of native prototypes', function() {
486
+ it('should allow extension of native prototypes', () => {
487
/*eslint-disable no-extend-native */
488
String.prototype.key = 'react';
489
Number.prototype.key = 'rocks';
@@ -516,7 +516,7 @@ describe('traverseAllChildren', function() {
516
delete Number.prototype.key;
517
});
518
519
- it('should throw on object', function() {
519
+ it('should throw on object', () => {
520
expect(function() {
521
traverseAllChildren({a: 1, b: 2}, function() {}, null);
522
}).toThrowError(
@@ -527,7 +527,7 @@ describe('traverseAllChildren', function() {
527
);
528
});
529
530
- it('should throw on regex', function() {
530
+ it('should throw on regex', () => {
531
// Really, we care about dates (#4840) but those have nondeterministic
532
// serialization (timezones) so let's test a regex instead:
533
expect(function() {
@@ -539,7 +539,7 @@ describe('traverseAllChildren', function() {
539
);
540
});
541
542
- it('should warn for using maps as children with owner info', function() {
542
+ it('should warn for using maps as children with owner info', () => {
543
spyOn(console, 'error');
544
545
class Parent extends React.Component {
src/test/__tests__/ReactTestUtils-test.js
+25
-25
@@ -16,16 +16,16 @@ var ReactDOM;
16
var ReactDOMServer;
17
var ReactTestUtils;
18
19
-describe('ReactTestUtils', function() {
19
+describe('ReactTestUtils', () => {
20
21
- beforeEach(function() {
21
+ beforeEach(() => {
22
React = require('React');
23
ReactDOM = require('ReactDOM');
24
ReactDOMServer = require('ReactDOMServer');
25
ReactTestUtils = require('ReactTestUtils');
26
});
27
28
- it('should have shallow rendering', function() {
28
+ it('should have shallow rendering', () => {
29
class SomeComponent extends React.Component {
30
render() {
31
return (
@@ -47,7 +47,7 @@ describe('ReactTestUtils', function() {
47
]);
48
});
49
50
- it('should shallow render a functional component', function() {
50
+ it('should shallow render a functional component', () => {
51
function SomeComponent() {
52
return (
53
<div>
@@ -67,7 +67,7 @@ describe('ReactTestUtils', function() {
67
]);
68
});
69
70
- it('should throw for invalid elements', function() {
70
+ it('should throw for invalid elements', () => {
71
class SomeComponent extends React.Component {
72
render() {
73
return <div />;
@@ -88,7 +88,7 @@ describe('ReactTestUtils', function() {
88
);
89
});
90
91
- it('should have shallow unmounting', function() {
91
+ it('should have shallow unmounting', () => {
92
var componentWillUnmount = jest.fn();
93
94
var SomeComponent = React.createClass({
@@ -105,7 +105,7 @@ describe('ReactTestUtils', function() {
105
expect(componentWillUnmount).toBeCalled();
106
});
107
108
- it('can shallow render to null', function() {
108
+ it('can shallow render to null', () => {
109
class SomeComponent extends React.Component {
110
render() {
111
return null;
@@ -118,7 +118,7 @@ describe('ReactTestUtils', function() {
118
expect(result).toBe(null);
119
});
120
121
- it('can shallow render with a ref', function() {
121
+ it('can shallow render with a ref', () => {
122
class SomeComponent extends React.Component {
123
render() {
124
return <div ref="hello" />;
@@ -130,7 +130,7 @@ describe('ReactTestUtils', function() {
130
shallowRenderer.render(<SomeComponent />);
131
});
132
133
- it('lets you update shallowly rendered components', function() {
133
+ it('lets you update shallowly rendered components', () => {
134
class SomeComponent extends React.Component {
135
state = {clicked: false};
136
@@ -180,7 +180,7 @@ describe('ReactTestUtils', function() {
180
expect(updatedResultCausedByClick.props.className).toBe('was-clicked');
181
});
182
183
- it('can access the mounted component instance', function() {
183
+ it('can access the mounted component instance', () => {
184
class SimpleComponent extends React.Component {
185
someMethod = () => {
186
return this.props.n;
@@ -196,7 +196,7 @@ describe('ReactTestUtils', function() {
196
expect(shallowRenderer.getMountedInstance().someMethod()).toEqual(5);
197
});
198
199
- it('can shallowly render components with contextTypes', function() {
199
+ it('can shallowly render components with contextTypes', () => {
200
class SimpleComponent extends React.Component {
201
static contextTypes = {
202
name: React.PropTypes.string,
@@ -212,7 +212,7 @@ describe('ReactTestUtils', function() {
212
expect(result).toEqual(<div />);
213
});
214
215
- it('can shallowly render components with ref as function', function() {
215
+ it('can shallowly render components with ref as function', () => {
216
class SimpleComponent extends React.Component {
217
state = {clicked: false};
218
@@ -243,7 +243,7 @@ describe('ReactTestUtils', function() {
243
expect(result.props.className).toEqual('clicked');
244
});
245
246
- it('can setState in componentWillMount when shallow rendering', function() {
246
+ it('can setState in componentWillMount when shallow rendering', () => {
247
class SimpleComponent extends React.Component {
248
componentWillMount() {
249
this.setState({groovy: 'doovy'});
@@ -259,7 +259,7 @@ describe('ReactTestUtils', function() {
259
expect(result).toEqual(<div>doovy</div>);
260
});
261
262
- it('can pass context when shallowly rendering', function() {
262
+ it('can pass context when shallowly rendering', () => {
263
class SimpleComponent extends React.Component {
264
static contextTypes = {
265
name: React.PropTypes.string,
@@ -277,7 +277,7 @@ describe('ReactTestUtils', function() {
277
expect(result).toEqual(<div>foo</div>);
278
});
279
280
- it('can fail context when shallowly rendering', function() {
280
+ it('can fail context when shallowly rendering', () => {
281
spyOn(console, 'error');
282
283
class SimpleComponent extends React.Component {
@@ -302,7 +302,7 @@ describe('ReactTestUtils', function() {
302
);
303
});
304
305
- it('can scryRenderedDOMComponentsWithClass with TextComponent', function() {
305
+ it('can scryRenderedDOMComponentsWithClass with TextComponent', () => {
306
class Wrapper extends React.Component {
307
render() {
308
return <div>Hello <span>Jim</span></div>;
@@ -317,7 +317,7 @@ describe('ReactTestUtils', function() {
317
expect(scryResults.length).toBe(0);
318
});
319
320
- it('can scryRenderedDOMComponentsWithClass with className contains \\n', function() {
320
+ it('can scryRenderedDOMComponentsWithClass with className contains \\n', () => {
321
class Wrapper extends React.Component {
322
render() {
323
return <div>Hello <span className={'x\ny'}>Jim</span></div>;
@@ -332,7 +332,7 @@ describe('ReactTestUtils', function() {
332
expect(scryResults.length).toBe(1);
333
});
334
335
- it('can scryRenderedDOMComponentsWithClass with multiple classes', function() {
335
+ it('can scryRenderedDOMComponentsWithClass with multiple classes', () => {
336
class Wrapper extends React.Component {
337
render() {
338
return <div>Hello <span className={'x y z'}>Jim</span></div>;
@@ -374,7 +374,7 @@ describe('ReactTestUtils', function() {
374
expect(scryResults5.length).toBe(0);
375
});
376
377
- it('traverses children in the correct order', function() {
377
+ it('traverses children in the correct order', () => {
378
class Wrapper extends React.Component {
379
render() {
380
return <div>{this.props.children}</div>;
@@ -408,7 +408,7 @@ describe('ReactTestUtils', function() {
408
expect(log).toEqual(['orangepurple', 'orange', 'purple']);
409
});
410
411
- it('should support injected wrapper components as DOM components', function() {
411
+ it('should support injected wrapper components as DOM components', () => {
412
var getTestDocument = require('getTestDocument');
413
414
var injectedDOMComponents = [
@@ -459,7 +459,7 @@ describe('ReactTestUtils', function() {
459
expect(ReactTestUtils.isDOMComponent(component.refs.body)).toBe(true);
460
});
461
462
- it('should change the value of an input field', function() {
462
+ it('should change the value of an input field', () => {
463
var obj = {
464
handler: function(e) {
465
e.persist();
@@ -476,7 +476,7 @@ describe('ReactTestUtils', function() {
476
expect(obj.handler).toHaveBeenCalledWith(jasmine.objectContaining({target: node}));
477
});
478
479
- it('should change the value of an input field in a component', function() {
479
+ it('should change the value of an input field in a component', () => {
480
class SomeComponent extends React.Component {
481
render() {
482
return (
@@ -503,7 +503,7 @@ describe('ReactTestUtils', function() {
503
expect(obj.handler).toHaveBeenCalledWith(jasmine.objectContaining({target: node}));
504
});
505
506
- it('should throw when attempting to use ReactTestUtils.Simulate with shallow rendering', function() {
506
+ it('should throw when attempting to use ReactTestUtils.Simulate with shallow rendering', () => {
507
class SomeComponent extends React.Component {
508
render() {
509
return (
@@ -525,7 +525,7 @@ describe('ReactTestUtils', function() {
525
expect(handler).not.toHaveBeenCalled();
526
});
527
528
- it('should not warn when simulating events with extra properties', function() {
528
+ it('should not warn when simulating events with extra properties', () => {
529
spyOn(console, 'error');
530
531
var CLIENT_X = 100;
@@ -549,7 +549,7 @@ describe('ReactTestUtils', function() {
549
expect(console.error.calls.count()).toBe(0);
550
});
551
552
- it('can scry with stateless components involved', function() {
552
+ it('can scry with stateless components involved', () => {
553
var Stateless = () => <div><hr /></div>;
554
555
class SomeComponent extends React.Component {
src/test/__tests__/reactComponentExpect-test.js
+3
-3
@@ -15,15 +15,15 @@ var React;
15
var ReactTestUtils;
16
var reactComponentExpect;
17
18
-describe('reactComponentExpect', function() {
18
+describe('reactComponentExpect', () => {
19
20
- beforeEach(function() {
20
+ beforeEach(() => {
21
React = require('React');
22
ReactTestUtils = require('ReactTestUtils');
23
reactComponentExpect = require('reactComponentExpect');
24
});
25
26
- it('should detect text components', function() {
26
+ it('should detect text components', () => {
27
class SomeComponent extends React.Component {
28
render() {
29
return (