Skip to content

Commit 881c9b5

Browse files
committed
Merge pull request facebook#2435 from sebmarkbage/fixretest
Use dump cache and remove factory from ReactElement-test
2 parents d8ed3e5 + 7f7b7f3 commit 881c9b5

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/core/__tests__/ReactElement-test.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ var ReactElement;
1616
var ReactTestUtils;
1717

1818
describe('ReactElement', function() {
19-
var ComponentFactory;
2019
var ComponentClass;
2120

2221
beforeEach(function() {
22+
require('mock-modules').dumpCache();
23+
2324
React = require('React');
2425
ReactElement = require('ReactElement');
2526
ReactTestUtils = require('ReactTestUtils');
26-
ComponentFactory = React.createClass({
27+
ComponentClass = React.createClass({
2728
render: function() { return <div />; }
2829
});
29-
ComponentClass = ComponentFactory;
3030
});
3131

3232
it('returns a complete element according to spec', function() {
33-
var element = React.createFactory(ComponentFactory)();
33+
var element = React.createFactory(ComponentClass)();
3434
expect(element.type).toBe(ComponentClass);
3535
expect(element.key).toBe(null);
3636
expect(element.ref).toBe(null);
@@ -46,20 +46,20 @@ describe('ReactElement', function() {
4646
});
4747

4848
it('returns an immutable element', function() {
49-
var element = React.createFactory(ComponentFactory)();
49+
var element = React.createFactory(ComponentClass)();
5050
expect(() => element.type = 'div').toThrow();
5151
});
5252

5353
it('does not reuse the original config object', function() {
5454
var config = { foo: 1 };
55-
var element = React.createFactory(ComponentFactory)(config);
55+
var element = React.createFactory(ComponentClass)(config);
5656
expect(element.props.foo).toBe(1);
5757
config.foo = 2;
5858
expect(element.props.foo).toBe(1);
5959
});
6060

6161
it('extracts key and ref from the config', function() {
62-
var element = React.createFactory(ComponentFactory)({
62+
var element = React.createFactory(ComponentClass)({
6363
key: '12',
6464
ref: '34',
6565
foo: '56'
@@ -71,7 +71,7 @@ describe('ReactElement', function() {
7171
});
7272

7373
it('coerces the key to a string', function() {
74-
var element = React.createFactory(ComponentFactory)({
74+
var element = React.createFactory(ComponentClass)({
7575
key: 12,
7676
foo: '56'
7777
});
@@ -83,7 +83,7 @@ describe('ReactElement', function() {
8383

8484
it('treats a null key as omitted but warns', function() {
8585
spyOn(console, 'warn');
86-
var element = React.createFactory(ComponentFactory)({
86+
var element = React.createFactory(ComponentClass)({
8787
key: null,
8888
foo: '56'
8989
});
@@ -98,7 +98,7 @@ describe('ReactElement', function() {
9898
});
9999

100100
it('preserves the context on the element', function() {
101-
var Component = React.createFactory(ComponentFactory);
101+
var Component = React.createFactory(ComponentClass);
102102
var element;
103103

104104
var Wrapper = React.createClass({
@@ -120,7 +120,7 @@ describe('ReactElement', function() {
120120
});
121121

122122
it('preserves the owner on the element', function() {
123-
var Component = React.createFactory(ComponentFactory);
123+
var Component = React.createFactory(ComponentClass);
124124
var element;
125125

126126
var Wrapper = React.createClass({
@@ -144,7 +144,7 @@ describe('ReactElement', function() {
144144
it('merges an additional argument onto the children prop', function() {
145145
spyOn(console, 'warn');
146146
var a = 1;
147-
var element = React.createFactory(ComponentFactory)({
147+
var element = React.createFactory(ComponentClass)({
148148
children: 'text'
149149
}, a);
150150
expect(element.props.children).toBe(a);
@@ -153,7 +153,7 @@ describe('ReactElement', function() {
153153

154154
it('does not override children if no rest args are provided', function() {
155155
spyOn(console, 'warn');
156-
var element = React.createFactory(ComponentFactory)({
156+
var element = React.createFactory(ComponentClass)({
157157
children: 'text'
158158
});
159159
expect(element.props.children).toBe('text');
@@ -162,7 +162,7 @@ describe('ReactElement', function() {
162162

163163
it('overrides children if null is provided as an argument', function() {
164164
spyOn(console, 'warn');
165-
var element = React.createFactory(ComponentFactory)({
165+
var element = React.createFactory(ComponentClass)({
166166
children: 'text'
167167
}, null);
168168
expect(element.props.children).toBe(null);
@@ -172,14 +172,14 @@ describe('ReactElement', function() {
172172
it('merges rest arguments onto the children prop in an array', function() {
173173
spyOn(console, 'warn');
174174
var a = 1, b = 2, c = 3;
175-
var element = React.createFactory(ComponentFactory)(null, a, b, c);
175+
var element = React.createFactory(ComponentClass)(null, a, b, c);
176176
expect(element.props.children).toEqual([1, 2, 3]);
177177
expect(console.warn.argsForCall.length).toBe(0);
178178
});
179179

180180
it('warns for keys for arrays of elements in rest args', function() {
181181
spyOn(console, 'warn');
182-
var Component = React.createFactory(ComponentFactory);
182+
var Component = React.createFactory(ComponentClass);
183183

184184
Component(null, [ Component(), Component() ]);
185185

@@ -191,7 +191,7 @@ describe('ReactElement', function() {
191191

192192
it('warns for keys for iterables of elements in rest args', function() {
193193
spyOn(console, 'warn');
194-
var Component = React.createFactory(ComponentFactory);
194+
var Component = React.createFactory(ComponentClass);
195195

196196
var iterable = {
197197
'@@iterator': function() {
@@ -215,7 +215,7 @@ describe('ReactElement', function() {
215215

216216
it('does not warns for arrays of elements with keys', function() {
217217
spyOn(console, 'warn');
218-
var Component = React.createFactory(ComponentFactory);
218+
var Component = React.createFactory(ComponentClass);
219219

220220
Component(null, [ Component({key: '#1'}), Component({key: '#2'}) ]);
221221

@@ -224,7 +224,7 @@ describe('ReactElement', function() {
224224

225225
it('does not warns for iterable elements with keys', function() {
226226
spyOn(console, 'warn');
227-
var Component = React.createFactory(ComponentFactory);
227+
var Component = React.createFactory(ComponentClass);
228228

229229
var iterable = {
230230
'@@iterator': function() {
@@ -248,7 +248,7 @@ describe('ReactElement', function() {
248248

249249
it('warns for numeric keys on objects in rest args', function() {
250250
spyOn(console, 'warn');
251-
var Component = React.createFactory(ComponentFactory);
251+
var Component = React.createFactory(ComponentClass);
252252

253253
Component(null, { 1: Component(), 2: Component() });
254254

@@ -260,7 +260,7 @@ describe('ReactElement', function() {
260260

261261
it('does not warn for numeric keys in entry iterables in rest args', function() {
262262
spyOn(console, 'warn');
263-
var Component = React.createFactory(ComponentFactory);
263+
var Component = React.createFactory(ComponentClass);
264264

265265
var iterable = {
266266
'@@iterator': function() {
@@ -282,7 +282,7 @@ describe('ReactElement', function() {
282282

283283
it('does not warn when the element is directly in rest args', function() {
284284
spyOn(console, 'warn');
285-
var Component = React.createFactory(ComponentFactory);
285+
var Component = React.createFactory(ComponentClass);
286286

287287
Component(null, Component(), Component());
288288

@@ -291,7 +291,7 @@ describe('ReactElement', function() {
291291

292292
it('does not warn when the array contains a non-element', function() {
293293
spyOn(console, 'warn');
294-
var Component = React.createFactory(ComponentFactory);
294+
var Component = React.createFactory(ComponentClass);
295295

296296
Component(null, [ {}, {} ]);
297297

0 commit comments

Comments
 (0)