1
1
import React from 'react' ;
2
- import { mount } from 'enzyme ' ;
2
+ import { render } from './utils ' ;
3
3
4
4
import CSSTransition from '../src/CSSTransition' ;
5
5
import TransitionGroup from '../src/TransitionGroup' ;
6
6
7
7
describe ( 'CSSTransition' , ( ) => {
8
8
it ( 'should flush new props to the DOM before initiating a transition' , ( done ) => {
9
9
const nodeRef = React . createRef ( ) ;
10
- const wrapper = mount (
10
+ const { setProps } = render (
11
11
< CSSTransition
12
12
in = { false }
13
13
nodeRef = { nodeRef }
@@ -29,28 +29,23 @@ describe('CSSTransition', () => {
29
29
30
30
expect ( nodeRef . current . classList . contains ( 'test-class' ) ) . toEqual ( false ) ;
31
31
32
- wrapper . setProps ( {
32
+ setProps ( {
33
33
in : true ,
34
34
className : 'test-class' ,
35
35
} ) ;
36
36
} ) ;
37
37
38
38
describe ( 'entering' , ( ) => {
39
- let wrapper , nodeRef ;
40
-
41
- beforeEach ( ( ) => {
42
- nodeRef = React . createRef ( ) ;
43
- wrapper = mount (
39
+ it ( 'should apply classes at each transition state' , ( done ) => {
40
+ let count = 0 ;
41
+ const nodeRef = React . createRef ( ) ;
42
+ const { setProps } = render (
44
43
< CSSTransition nodeRef = { nodeRef } timeout = { 10 } classNames = "test" >
45
44
< div ref = { nodeRef } />
46
45
</ CSSTransition >
47
46
) ;
48
- } ) ;
49
-
50
- it ( 'should apply classes at each transition state' , ( done ) => {
51
- let count = 0 ;
52
47
53
- wrapper . setProps ( {
48
+ setProps ( {
54
49
in : true ,
55
50
56
51
onEnter ( ) {
@@ -76,7 +71,7 @@ describe('CSSTransition', () => {
76
71
it ( 'should apply custom classNames names' , ( done ) => {
77
72
let count = 0 ;
78
73
const nodeRef = React . createRef ( ) ;
79
- wrapper = mount (
74
+ const { setProps } = render (
80
75
< CSSTransition
81
76
timeout = { 10 }
82
77
nodeRef = { nodeRef }
@@ -90,7 +85,7 @@ describe('CSSTransition', () => {
90
85
</ CSSTransition >
91
86
) ;
92
87
93
- wrapper . setProps ( {
88
+ setProps ( {
94
89
in : true ,
95
90
96
91
onEnter ( ) {
@@ -118,7 +113,7 @@ describe('CSSTransition', () => {
118
113
it ( 'should apply appear classes at each transition state' , ( done ) => {
119
114
let count = 0 ;
120
115
const nodeRef = React . createRef ( ) ;
121
- mount (
116
+ render (
122
117
< CSSTransition
123
118
timeout = { 10 }
124
119
nodeRef = { nodeRef }
@@ -153,20 +148,20 @@ describe('CSSTransition', () => {
153
148
154
149
it ( 'should lose the "*-appear-done" class after leaving and entering again' , ( done ) => {
155
150
const nodeRef = React . createRef ( ) ;
156
- const wrapper = mount (
151
+ const { setProps } = render (
157
152
< CSSTransition
158
153
timeout = { 10 }
159
154
nodeRef = { nodeRef }
160
155
classNames = "appear-test"
161
156
in = { true }
162
157
appear = { true }
163
158
onEntered = { ( ) => {
164
- wrapper . setProps ( {
159
+ setProps ( {
165
160
in : false ,
166
161
onEntered : ( ) => { } ,
167
162
onExited : ( ) => {
168
163
expect ( nodeRef . current . className ) . toBe ( 'appear-test-exit-done' ) ;
169
- wrapper . setProps ( {
164
+ setProps ( {
170
165
in : true ,
171
166
onEntered : ( ) => {
172
167
expect ( nodeRef . current . className ) . toBe (
@@ -186,7 +181,7 @@ describe('CSSTransition', () => {
186
181
187
182
it ( 'should not add undefined when appearDone is not defined' , ( done ) => {
188
183
const nodeRef = React . createRef ( ) ;
189
- mount (
184
+ render (
190
185
< CSSTransition
191
186
timeout = { 10 }
192
187
nodeRef = { nodeRef }
@@ -211,7 +206,7 @@ describe('CSSTransition', () => {
211
206
it ( 'should not be appearing in normal enter mode' , ( done ) => {
212
207
let count = 0 ;
213
208
const nodeRef = React . createRef ( ) ;
214
- mount (
209
+ render (
215
210
< CSSTransition
216
211
timeout = { 10 }
217
212
nodeRef = { nodeRef }
@@ -250,7 +245,7 @@ describe('CSSTransition', () => {
250
245
251
246
it ( 'should not enter the transition states when appear=false' , ( ) => {
252
247
const nodeRef = React . createRef ( ) ;
253
- mount (
248
+ render (
254
249
< CSSTransition
255
250
timeout = { 10 }
256
251
nodeRef = { nodeRef }
@@ -274,21 +269,16 @@ describe('CSSTransition', () => {
274
269
} ) ;
275
270
276
271
describe ( 'exiting' , ( ) => {
277
- let wrapper , nodeRef ;
278
-
279
- beforeEach ( ( ) => {
280
- nodeRef = React . createRef ( ) ;
281
- wrapper = mount (
272
+ it ( 'should apply classes at each transition state' , ( done ) => {
273
+ let count = 0 ;
274
+ const nodeRef = React . createRef ( ) ;
275
+ const { setProps } = render (
282
276
< CSSTransition in nodeRef = { nodeRef } timeout = { 10 } classNames = "test" >
283
277
< div ref = { nodeRef } />
284
278
</ CSSTransition >
285
279
) ;
286
- } ) ;
287
-
288
- it ( 'should apply classes at each transition state' , ( done ) => {
289
- let count = 0 ;
290
280
291
- wrapper . setProps ( {
281
+ setProps ( {
292
282
in : false ,
293
283
294
284
onExit ( ) {
@@ -314,7 +304,7 @@ describe('CSSTransition', () => {
314
304
it ( 'should apply custom classNames names' , ( done ) => {
315
305
let count = 0 ;
316
306
const nodeRef = React . createRef ( ) ;
317
- wrapper = mount (
307
+ const { setProps } = render (
318
308
< CSSTransition
319
309
in
320
310
nodeRef = { nodeRef }
@@ -329,7 +319,7 @@ describe('CSSTransition', () => {
329
319
</ CSSTransition >
330
320
) ;
331
321
332
- wrapper . setProps ( {
322
+ setProps ( {
333
323
in : false ,
334
324
335
325
onExit ( ) {
@@ -356,13 +346,13 @@ describe('CSSTransition', () => {
356
346
let count = 0 ;
357
347
358
348
const nodeRef = React . createRef ( ) ;
359
- const wrapper = mount (
349
+ const { setProps } = render (
360
350
< CSSTransition in nodeRef = { nodeRef } timeout = { 10 } >
361
351
< div ref = { nodeRef } />
362
352
</ CSSTransition >
363
353
) ;
364
354
365
- wrapper . setProps ( {
355
+ setProps ( {
366
356
in : false ,
367
357
368
358
onExit ( ) {
@@ -418,13 +408,13 @@ describe('CSSTransition', () => {
418
408
bar : React . createRef ( ) ,
419
409
} ;
420
410
421
- const wrapper = mount (
411
+ const { setProps } = render (
422
412
< Test direction = "down" text = "foo" nodeRef = { nodeRef . foo } />
423
413
) ;
424
414
425
415
const rerender = ( getProps ) =>
426
416
new Promise ( ( resolve ) =>
427
- wrapper . setProps ( {
417
+ setProps ( {
428
418
onEnter : undefined ,
429
419
onEntering : undefined ,
430
420
onEntered : undefined ,
0 commit comments