]> git.proxmox.com Git - extjs.git/blame - extjs/packages/charts/test/specs/draw/sprite/AnimationParser.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / charts / test / specs / draw / sprite / AnimationParser.js
CommitLineData
6527f429
DM
1describe('Ext.draw.sprite.AnimationParser', function () {\r
2\r
3 var parser = Ext.draw.sprite.AnimationParser;\r
4\r
5 describe("'data' (array) parser", function () {\r
6 var empty = [],\r
7 nonEmpty1 = [4, 8, 16, 32],\r
8 nonEmpty2 = [-4, -8, -16, -32],\r
9 smaller = [4, 8, 16],\r
10 bigger = [2, 4, 8, 16, 32],\r
11 punctured = [2, NaN, 8, null];\r
12\r
13 it('should be able to transition from an empty to a non-empty array', function () {\r
14 // Since no initial values were given, the compute will\r
15 // return the target array for any delta value.\r
16 var delta = 0.25;\r
17 var result = parser.data.compute(empty, nonEmpty1, delta);\r
18 expect(result).toEqual([4, 8, 16, 32]);\r
19 });\r
20\r
21 it('should be able to transition from a non-empty to an empty array', function () {\r
22 var delta = 0.25;\r
23 // Since we are transitioning to nothing, no intermediate\r
24 // value can be calculated. So the intermediate values\r
25 // are computed as if the target values were zeros.\r
26 var result = parser.data.compute(nonEmpty1, empty, delta);\r
27 expect(result).toEqual([3, 6, 12, 24]);\r
28 });\r
29\r
30 it('should be able to transition between two equal size arrays', function () {\r
31 var delta = 0.25;\r
32 // This is simply an interpolated value of the corresponding\r
33 // elements in respective arrays.\r
34 var result = parser.data.compute(nonEmpty1, nonEmpty2, delta);\r
35 expect(result).toEqual([2, 4, 8, 16]);\r
36 });\r
37\r
38 it('should be able to transition from a smaller to a bigger arrray', function () {\r
39 var delta = 0.5;\r
40 // This will interpolate between respective elements,\r
41 // until the smaller array is out of elements, but the\r
42 // bigger one still has some. In that case the interpolation\r
43 // will be made between the last element of the smaller\r
44 // array and the extra elements of the bigger array.\r
45 var result = parser.data.compute(smaller, bigger, delta);\r
46 expect(result).toEqual([3, 6, 12, 16, 24]);\r
47 });\r
48\r
49 it('should be able to transition from a bigger to a smaller array', function () {\r
50 var delta = 0.5;\r
51 // Behaves just like the interpolation from smaller to bigger.\r
52 var result = parser.data.compute(bigger, smaller, delta);\r
53 expect(result).toEqual([3, 6, 12, 16, 24]);\r
54 });\r
55\r
56 it('should be able to transition from a punctured to a normal array', function () {\r
57 var delta = 0.5;\r
58 // When invalid numbers in the punctured array are encountered,\r
59 // a value with the same index in the target array will be used\r
60 // for the resulting array.\r
61 var result = parser.data.compute(punctured, nonEmpty1, delta);\r
62 expect(result).toEqual([3, 8, 12, 32]);\r
63 });\r
64\r
65 it('should be able to transition from a normal to a punctured array', function () {\r
66 var delta = 0.5;\r
67 // Just like with transitioning to an empty array, if the value\r
68 // can't be found in the target array, a zero value will be used\r
69 // instead.\r
70 var result = parser.data.compute(nonEmpty1, punctured, delta);\r
71 expect(result).toEqual([3, 4, 12, 16]);\r
72 });\r
73 });\r
74\r
75});