diff options
author | Rémi Tétreault <tetreault.remi@gmail.com> | 2017-07-09 13:24:21 -0400 |
---|---|---|
committer | Rémi Tétreault <tetreault.remi@gmail.com> | 2017-07-09 13:24:21 -0400 |
commit | c9b762e3e36e0ec14a3d5934af8e6512192018c4 (patch) | |
tree | 3cf4d09058f9fad5377ff89c7f097fa2a05fd8b1 /spec | |
parent | a19b4f1dfe06d70775a03ec5428b0423fbb46819 (diff) | |
download | svg.js-c9b762e3e36e0ec14a3d5934af8e6512192018c4.tar.gz svg.js-c9b762e3e36e0ec14a3d5934af8e6512192018c4.zip |
Add tests for fix array values which were not animated (#698)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/fx.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/spec/fx.js b/spec/spec/fx.js index b1f0091..2df715a 100644 --- a/spec/spec/fx.js +++ b/spec/spec/fx.js @@ -2187,6 +2187,27 @@ describe('FX', function() { expect(line.attr('stroke-linecap')).toBe(endValue) }) + it('should be possible to animate array attributes', function() { + var startValue = [10,5] + , endValue = [20,10] + , morph = new SVG.Array(startValue).morph(endValue) + + rect.attr('stroke-dasharray', startValue) + fx.attr('stroke-dasharray', endValue) + + fx.start() + expect(rect.attr('stroke-dasharray')).toBe(morph.at(0).toString()) + + jasmine.clock().tick(250) // Have the animation be half way + fx.step() + expect(rect.attr('stroke-dasharray')).toBe(morph.at(0.5).toString()) + + jasmine.clock().tick(250) // Have the animation reach its end + fx.step() + expect(rect.attr('stroke-dasharray')).toBe(morph.at(1).toString()) + }) + + it('should be possible to animate color attributes by using SVG.Color', function() { var startValue = 'rgb(42,251,100)' , endValue = 'rgb(10,80,175)' @@ -2321,6 +2342,26 @@ describe('FX', function() { expect(line.style('stroke-linecap')).toBe(endValue) }) + it('should be possible to animate array styles', function() { + var startValue = [10,5] + , endValue = [20,10] + , morph = new SVG.Array(startValue).morph(endValue) + + rect.style('stroke-dasharray', startValue) + fx.style('stroke-dasharray', endValue) + + fx.start() + expect(rect.style('stroke-dasharray')).toBe(morph.at(0).valueOf().join(", ")) + + jasmine.clock().tick(250) // Have the animation be half way + fx.step() + expect(rect.style('stroke-dasharray')).toBe(morph.at(0.5).valueOf().join(", ")) + + jasmine.clock().tick(250) // Have the animation reach its end + fx.step() + expect(rect.style('stroke-dasharray')).toBe(morph.at(1).valueOf().join(", ")) + }) + it('should be possible to animate color styles by using SVG.Color', function() { var startValue = '#81DE01' , endValue = '#B1835D' @@ -2841,6 +2882,20 @@ describe('SVG.MorphObj', function() { expect(obj instanceof SVG.Number).toBeTruthy() }) + it('accepts arrays and converts them to SVG.Array', function () { + var obj = new SVG.MorphObj([1,2,3], [4,5,6]) + expect(obj instanceof SVG.Array).toBeTruthy() + + var obj = new SVG.MorphObj("1 2 3", "4 5 6") + expect(obj instanceof SVG.Array).toBeTruthy() + + var obj = new SVG.MorphObj("1,2,3", "4,5,6") + expect(obj instanceof SVG.Array).toBeTruthy() + + var obj = new SVG.MorphObj("1, 2, 3", "4, 5, 6") + expect(obj instanceof SVG.Array).toBeTruthy() + }) + it('accepts any other values', function() { var obj = new SVG.MorphObj('Hello', 'World') |