-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
55 lines (46 loc) · 1.52 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var Promise = require('bluebird');
require('gsap');
var animate = require('./')(Promise, TweenLite);
var test = require('tape').test;
test('Promise wrapper around gsap / tweenlite', function(t) {
t.test('Basic tests', function(st) {
st.plan(4);
st.equal(animate, animate.to, 'animate equals animate.to');
var a = { value: 0 };
animate.to(a, 0.5, { value: 1.0 }).then(function() {
st.equal(a.value, 1, 'animate.to works');
});
var b = { value: 5 };
animate.set(b, { delay: 0.5, value: 10 }).then(function() {
st.equal(b.value, 10, 'animate.set with delay works');
});
var c = { value: 10 };
animate.fromTo(c, 1.0, { value: 0 }, { value: 5 }).then(function() {
st.equal(c.value, 5, 'animate.fromTo works');
});
});
t.test('Promise all', function(st) {
st.plan(1);
var f = [{ value: 0 }, { value: 0 }, { value: 0 }, { value: 0 }, { value: 0 }, { value: 0 }];
var to = { value: 100 };
var timeout = setTimeout(function() {
st.fail('not all promises resolved, are arguments being mutated?');
}, 800);
Promise.all([
animate.set(f[0], to),
animate.set(f[1], to),
animate.to(f[2], 0.5, to),
animate.to(f[3], 0.5, to),
animate.fromTo(f[4], 0.5, { value: 0 }, to),
animate.fromTo(f[5], 0.5, { value: 0 }, to)
]).then(function() {
clearTimeout(timeout);
st.assert(
f.every(function(item) {
return item.value === to.value;
}),
'all promises resolved'
);
});
});
});