Skip to content

Commit 29d12be

Browse files
committed
fix tests
1 parent 3f51ea6 commit 29d12be

File tree

1 file changed

+38
-24
lines changed

1 file changed

+38
-24
lines changed

tests/index.js

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,30 @@ import expect from 'expect.js';
77
import QueueAnim from '../src';
88
import TestUtils from 'react-dom/test-utils';
99
import ticker from 'rc-tween-one/lib/ticker';
10-
import $ from 'jquery';
1110

1211
const defaultInterval = 100;
1312

1413
describe('rc-queue-anim', () => {
1514
let div;
1615

1716
function getOpacity(node) {
18-
return parseFloat($(node).css('opacity'));
17+
if (!node) {
18+
return null;
19+
}
20+
return parseFloat(window.getComputedStyle(node).opacity);
1921
}
2022

2123
function getLeft(node) {
24+
if (!node) {
25+
return null;
26+
}
2227
return parseFloat(node.style.left);
2328
}
2429

2530
function getTop(node) {
31+
if (!node) {
32+
return null;
33+
}
2634
return parseFloat(node.style.top);
2735
}
2836

@@ -81,7 +89,13 @@ describe('rc-queue-anim', () => {
8189
{!this.state.unMount ? <QueueAnim {...props}>
8290
{
8391
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+
) :
8599
null
86100
}
87101
{null}
@@ -238,7 +252,7 @@ describe('rc-queue-anim', () => {
238252
expect(getLeft(children[1])).to.be(100);
239253
expect(getTop(children[1])).to.be(100);
240254
done();
241-
}, 1000);
255+
}, 1030);
242256
});
243257

244258
it('should support animation when change direction at animating', (done) => {
@@ -352,31 +366,31 @@ describe('rc-queue-anim', () => {
352366
let children = TestUtils.scryRenderedDOMComponentsWithTag(instance, 'div');
353367
ticker.timeout(() => {
354368
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();
355375
ticker.timeout(() => {
356376
children = TestUtils.scryRenderedDOMComponentsWithTag(instance, 'div');
357-
expect(getLeft(children[1])).to.below(100);
377+
expect(getLeft(children[1])).to.be(0);
358378
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]));
366386
ticker.timeout(() => {
367387
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);
369390
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);
381395
});
382396
});

0 commit comments

Comments
 (0)