forked from newagebegins/BattleCity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimationSpec.js
40 lines (38 loc) · 1.38 KB
/
AnimationSpec.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
describe("Animation", function () {
it("no loop", function () {
var animation = new Animation([1,2]);
expect(animation.getFrame()).toEqual(1);
expect(animation.isCompleted()).toBeFalsy();
animation.update();
expect(animation.getFrame()).toEqual(2);
expect(animation.isCompleted()).toBeFalsy();
animation.update();
expect(animation.getFrame()).toEqual(2);
expect(animation.isCompleted()).toBeTruthy();
});
it("loop", function () {
var animation = new Animation([1,2], 1, true);
expect(animation.getFrame()).toEqual(1);
expect(animation.isCompleted()).toBeFalsy();
animation.update();
expect(animation.getFrame()).toEqual(2);
expect(animation.isCompleted()).toBeFalsy();
animation.update();
expect(animation.getFrame()).toEqual(1);
expect(animation.isCompleted()).toBeFalsy();
});
it("duration", function () {
var animation = new Animation([1,2], 2);
expect(animation.getFrame()).toEqual(1);
animation.update();
expect(animation.getFrame()).toEqual(1);
animation.update();
expect(animation.getFrame()).toEqual(2);
animation.update();
expect(animation.getFrame()).toEqual(2);
expect(animation.isCompleted()).toBeFalsy();
animation.update();
expect(animation.getFrame()).toEqual(2);
expect(animation.isCompleted()).toBeTruthy();
});
});