@@ -7,22 +7,30 @@ import expect from 'expect.js';
7
7
import QueueAnim from '../src' ;
8
8
import TestUtils from 'react-dom/test-utils' ;
9
9
import ticker from 'rc-tween-one/lib/ticker' ;
10
- import $ from 'jquery' ;
11
10
12
11
const defaultInterval = 100 ;
13
12
14
13
describe ( 'rc-queue-anim' , ( ) => {
15
14
let div ;
16
15
17
16
function getOpacity ( node ) {
18
- return parseFloat ( $ ( node ) . css ( 'opacity' ) ) ;
17
+ if ( ! node ) {
18
+ return null ;
19
+ }
20
+ return parseFloat ( window . getComputedStyle ( node ) . opacity ) ;
19
21
}
20
22
21
23
function getLeft ( node ) {
24
+ if ( ! node ) {
25
+ return null ;
26
+ }
22
27
return parseFloat ( node . style . left ) ;
23
28
}
24
29
25
30
function getTop ( node ) {
31
+ if ( ! node ) {
32
+ return null ;
33
+ }
26
34
return parseFloat ( node . style . top ) ;
27
35
}
28
36
@@ -81,7 +89,13 @@ describe('rc-queue-anim', () => {
81
89
{ ! this . state . unMount ? < QueueAnim { ...props } >
82
90
{
83
91
this . state . show ?
84
- this . state . items . map ( ( item ) => < div key = { item . key } > { item . content } </ div > ) :
92
+ this . state . items . map ( ( item ) =>
93
+ < div key = { item . key }
94
+ style = { { position : 'relative' } }
95
+ >
96
+ { item . content }
97
+ </ div >
98
+ ) :
85
99
null
86
100
}
87
101
{ null }
@@ -238,7 +252,7 @@ describe('rc-queue-anim', () => {
238
252
expect ( getLeft ( children [ 1 ] ) ) . to . be ( 100 ) ;
239
253
expect ( getTop ( children [ 1 ] ) ) . to . be ( 100 ) ;
240
254
done ( ) ;
241
- } , 1000 ) ;
255
+ } , 1030 ) ;
242
256
} ) ;
243
257
244
258
it ( 'should support animation when change direction at animating' , ( done ) => {
@@ -352,31 +366,31 @@ describe('rc-queue-anim', () => {
352
366
let children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
353
367
ticker . timeout ( ( ) => {
354
368
instance . toggle ( ) ;
369
+ children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
370
+ console . log ( 'left:' , getLeft ( children [ 1 ] ) ) ;
371
+ console . log ( 'top:' , getTop ( children [ 2 ] ) ) ;
372
+ expect ( getLeft ( children [ 1 ] ) ) . to . be ( 100 ) ;
373
+ expect ( getTop ( children [ 2 ] ) ) . to . be ( 100 ) ;
374
+ expect ( isNaN ( getTop ( children [ 1 ] ) ) ) . to . be . ok ( ) ;
355
375
ticker . timeout ( ( ) => {
356
376
children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
357
- expect ( getLeft ( children [ 1 ] ) ) . to . below ( 100 ) ;
377
+ expect ( getLeft ( children [ 1 ] ) ) . to . be ( 0 ) ;
358
378
expect ( isNaN ( getTop ( children [ 1 ] ) ) ) . to . be . ok ( ) ;
359
- console . log ( 'left :' , getLeft ( children [ 1 ] ) ) ;
360
- ticker . timeout ( ( ) => {
361
- children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
362
- expect ( getLeft ( children [ 1 ] ) ) . to . be ( 0 ) ;
363
- expect ( isNaN ( getTop ( children [ 1 ] ) ) ) . to . be . ok ( ) ;
364
- console . log ( 'left_end:' , getLeft ( children [ 1 ] ) ) ;
365
- } , 500 ) ;
379
+ console . log ( 'left_end :' , getLeft ( children [ 1 ] ) ) ;
380
+ } , 500 ) ;
381
+ ticker . timeout ( ( ) => {
382
+ children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
383
+ expect ( getTop ( children [ 2 ] ) ) . to . below ( 100 ) ;
384
+ expect ( isNaN ( getLeft ( children [ 2 ] ) ) ) . to . be . ok ( ) ;
385
+ console . log ( 'top:' , getTop ( children [ 2 ] ) ) ;
366
386
ticker . timeout ( ( ) => {
367
387
children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
368
- expect ( getTop ( children [ 2 ] ) ) . to . below ( 100 ) ;
388
+ console . log ( 'top_end:' , getTop ( children [ 2 ] ) ) ;
389
+ expect ( getTop ( children [ 2 ] ) ) . to . be ( 0 ) ;
369
390
expect ( isNaN ( getLeft ( children [ 2 ] ) ) ) . to . be . ok ( ) ;
370
- console . log ( 'top:' , getTop ( children [ 2 ] ) ) ;
371
- ticker . timeout ( ( ) => {
372
- children = TestUtils . scryRenderedDOMComponentsWithTag ( instance , 'div' ) ;
373
- console . log ( 'top_end:' , getTop ( children [ 2 ] ) ) ;
374
- expect ( getTop ( children [ 2 ] ) ) . to . be ( 0 ) ;
375
- expect ( isNaN ( getLeft ( children [ 2 ] ) ) ) . to . be . ok ( ) ;
376
- done ( ) ;
377
- } , 500 ) ;
378
- } , 110 ) ;
379
- } , 18 ) ;
380
- } , 1000 ) ;
391
+ done ( ) ;
392
+ } , 500 ) ;
393
+ } , 118 ) ;
394
+ } , 1018 ) ;
381
395
} ) ;
382
396
} ) ;
0 commit comments