]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | describe("Ext.fx.Anim", function() {\r |
2 | var anim, target, animEndSpy;\r | |
3 | \r | |
4 | beforeEach(function() {\r | |
5 | target = Ext.getBody().createChild({cls: 'fxtarget'});\r | |
6 | spyOn(Ext.fx.Anim.prototype, "end").andCallThrough();\r | |
7 | });\r | |
8 | \r | |
9 | afterEach(function() {\r | |
10 | target.destroy();\r | |
11 | });\r | |
12 | \r | |
13 | describe("instantiation", function(){\r | |
14 | beforeEach(function() {\r | |
15 | spyOn(Ext.fx.Manager, "addAnim"); //avoid animation start\r | |
16 | anim = new Ext.fx.Anim({\r | |
17 | target: target\r | |
18 | });\r | |
19 | });\r | |
20 | \r | |
21 | it("should mix in Ext.util.Observable", function(){\r | |
22 | expect(anim.mixins.observable).toEqual(Ext.util.Observable.prototype);\r | |
23 | });\r | |
24 | \r | |
25 | it("should have a default duration configuration option equal to 250", function() {\r | |
26 | expect(anim.duration).toEqual(250);\r | |
27 | });\r | |
28 | \r | |
29 | it("should have a default delay configuration option equal to 0", function(){\r | |
30 | expect(anim.delay).toEqual(0);\r | |
31 | });\r | |
32 | \r | |
33 | it("should have a default easing configuration option equal to ease", function(){\r | |
34 | expect(anim.easing).toEqual('ease');\r | |
35 | });\r | |
36 | \r | |
37 | it("should have a default reverse configuration option equal to false", function(){\r | |
38 | expect(anim.reverse).toBe(false);\r | |
39 | });\r | |
40 | \r | |
41 | it("should have a default running configuration option equal to false", function(){\r | |
42 | expect(anim.running).toBe(false);\r | |
43 | });\r | |
44 | \r | |
45 | it("should have a default paused configuration option equal to false", function(){\r | |
46 | expect(anim.paused).toBe(false);\r | |
47 | });\r | |
48 | \r | |
49 | it("should have a default iterations configuration option equal to 1", function(){\r | |
50 | expect(anim.iterations).toEqual(1);\r | |
51 | });\r | |
52 | \r | |
53 | it("should have a default currentIteration configuration option equal to 0", function(){\r | |
54 | expect(anim.currentIteration).toEqual(0);\r | |
55 | });\r | |
56 | \r | |
57 | it("should have a default startTime configuration option equal to 0", function(){\r | |
58 | expect(anim.startTime).toEqual(0);\r | |
59 | });\r | |
60 | });\r | |
61 | \r | |
62 | describe("events", function(){\r | |
63 | beforeEach(function(){\r | |
64 | spyOn(Ext.fx.Anim.prototype, "fireEvent").andCallThrough();\r | |
65 | \r | |
66 | anim = new Ext.fx.Anim({\r | |
67 | target: target,\r | |
68 | duration: 1,\r | |
69 | from: {\r | |
70 | opacity: 0\r | |
71 | },\r | |
72 | to: {\r | |
73 | opacity: 1\r | |
74 | }\r | |
75 | });\r | |
76 | });\r | |
77 | \r | |
78 | it("should fire beforeanimate and afteranimate", function(){\r | |
79 | waitsFor(function() {\r | |
80 | return Ext.fx.Anim.prototype.end.calls.length === 1;\r | |
81 | }, "event firing was never completed");\r | |
82 | \r | |
83 | runs(function(){\r | |
84 | expect(Ext.fx.Anim.prototype.fireEvent).toHaveBeenCalledWith("beforeanimate", anim);\r | |
85 | expect(Ext.fx.Anim.prototype.fireEvent.calls[1].args[0]).toEqual("afteranimate");\r | |
86 | expect(Ext.fx.Anim.prototype.fireEvent.calls[1].args[1]).toEqual(anim);\r | |
87 | });\r | |
88 | });\r | |
89 | });\r | |
90 | \r | |
91 | describe("opacity", function(){\r | |
92 | beforeEach(function(){\r | |
93 | anim = new Ext.fx.Anim({\r | |
94 | target: target,\r | |
95 | duration: 1,\r | |
96 | from: {\r | |
97 | opacity: 0\r | |
98 | },\r | |
99 | to: {\r | |
100 | opacity: 1\r | |
101 | }\r | |
102 | });\r | |
103 | \r | |
104 | waitsFor(function() {\r | |
105 | return Ext.fx.Anim.prototype.end.calls.length === 1;\r | |
106 | }, "event firing was never completed");\r | |
107 | });\r | |
108 | \r | |
109 | it("should change opacity", function(){\r | |
110 | if(Ext.isIE || Ext.isOpera){\r | |
111 | expect(target.dom.style.filter).toEqual("");\r | |
112 | } else {\r | |
113 | expect(target.dom.style.opacity).toEqual("1");\r | |
114 | }\r | |
115 | });\r | |
116 | });\r | |
117 | \r | |
118 | describe("color", function(){\r | |
119 | describe("hexadecimal colors", function(){\r | |
120 | beforeEach(function(){\r | |
121 | anim = new Ext.fx.Anim({\r | |
122 | target: target,\r | |
123 | duration: 1,\r | |
124 | from: {\r | |
125 | color: "#000000"\r | |
126 | },\r | |
127 | to: {\r | |
128 | color: "#f1c101"\r | |
129 | }\r | |
130 | });\r | |
131 | \r | |
132 | waitsFor(function() {\r | |
133 | return Ext.fx.Anim.prototype.end.calls.length === 1;\r | |
134 | }, "event firing was never completed");\r | |
135 | });\r | |
136 | \r | |
137 | it("should change color", function(){\r | |
138 | // IE8 there aren't spaces after the commas, for other browsers there are\r | |
139 | var color = target.dom.style.color.replace(/ /g, '');\r | |
140 | \r | |
141 | if (color.charAt(0) === '#') {\r | |
142 | // Old Opera (not sure which versions exactly but pre-11.51)\r | |
143 | expect(color).toEqual("#f1c101");\r | |
144 | }\r | |
145 | else {\r | |
146 | expect(color).toEqual("rgb(241,193,1)");\r | |
147 | }\r | |
148 | });\r | |
149 | });\r | |
150 | \r | |
151 | xdescribe("shorthand hexadecimal colors", function(){\r | |
152 | beforeEach(function(){\r | |
153 | anim = new Ext.fx.Anim({\r | |
154 | target: target,\r | |
155 | duration: 1,\r | |
156 | from: {\r | |
157 | color: "#000000"\r | |
158 | },\r | |
159 | to: {\r | |
160 | color: "#fc0"\r | |
161 | }\r | |
162 | });\r | |
163 | });\r | |
164 | \r | |
165 | it("should change color", function(){\r | |
166 | waitsFor(function(){\r | |
167 | var style = target.dom.style;\r | |
168 | return style.color === 'rgb(255, 204, 0)';\r | |
169 | }, "color wasn't changed");\r | |
170 | });\r | |
171 | });\r | |
172 | \r | |
173 | });\r | |
174 | });\r |