forked from mattdesl/keytime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
62 lines (48 loc) · 1.91 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
56
57
58
59
60
61
62
import Timeline from './';
import { test } from 'tape';
var data1 = [
{ name: 'position', value: [20, 20] },
{ name: 'fill', keyframes: [
{ time: 0, value: [0, 0, 0] },
{ time: 1, value: [255, 255, 255], ease: 'linear' }
]},
{ name: 'stroke', keyframes: [
{ time: 0, value: [0, 0, 0] },
{ time: 1, value: [255, 255, 255], ease: 'expoOut' },
{ time: 10, value: [255, 255, 255] }
]},
]
test('timeline should be correct', function(t) {
var timeline = Timeline(data1)
var timeline2 = Timeline()
timeline2.load(data1)
var fill = timeline.property('fill')
var stroke = timeline.property('stroke')
var position = timeline.property('position')
t.deepEqual(timeline.properties, timeline2.properties, 'constructor and load have same effect')
t.ok( fill, 'gets property')
t.equal(timeline.property('fill'), timeline.property(1), 'property accepts index or name')
t.deepEqual( timeline.valueOf(10, position), [20,20], 'retrieves value' )
t.deepEqual( timeline.valueOf(0, fill), [0,0,0], 'retrieves keyframe' )
t.deepEqual( timeline.valueOf(0.5, fill), [127.5,127.5,127.5], 'interpolates keyframes' )
t.notDeepEqual( timeline.valueOf(0.5, stroke), [127.5,127.5,127.5], 'eases value' )
t.equal( timeline.duration(), 10, 'duration is correct' )
//add a property
var borderData = { name: 'border-radius', value: 25, hidden: true }
timeline.addProperty(borderData)
t.equal( timeline.valueOf(0, timeline.property('border-radius')), 25, 'adds property' )
var result = {
position: [20,20],
fill: [255,255,255],
stroke: [255,255,255],
'border-radius': 25
}
var values = timeline.values(1)
t.deepEqual(values, result, 'values() gets correct object')
var border = timeline.property('border-radius')
t.equal(border.hidden, true, 'stores custom properties')
//exported data always includes value and keyframes
borderData.keyframes = []
t.deepEqual( border.export(), borderData, 'property.export() works' )
t.end()
})