summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-05-31 21:30:10 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-05-31 21:30:10 +0200
commitd215d392ef980e9e92c62fb124bbbd8b2ee11ac2 (patch)
treebed645c2ad92f6549eb607bac731e5841fec4278 /spec
parentaa1a55f92a44ced1645b7ebafad0968caea817ed (diff)
downloadsvg.js-d215d392ef980e9e92c62fb124bbbd8b2ee11ac2.tar.gz
svg.js-d215d392ef980e9e92c62fb124bbbd8b2ee11ac2.zip
fix for the endvalue of the animation
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/runner.js249
1 files changed, 240 insertions, 9 deletions
diff --git a/spec/spec/runner.js b/spec/spec/runner.js
index e90bb57..2f889f3 100644
--- a/spec/spec/runner.js
+++ b/spec/spec/runner.js
@@ -254,19 +254,250 @@ describe('SVG.Runner', function () {
expect(runFn).toHaveBeenCalledWith(1)
})
- it('does behave correctly at the end of reversed loop', function () {
- var spy = jasmine.createSpy('stepper')
- var runner = new SVG.Runner(1000).loop(6, true)
- runner.queue(null, spy)
- // the 6th loop is reversed
- runner.step(5750)
- expect(spy).toHaveBeenCalledWith(0.25)
- runner.step(250)
- expect(spy).toHaveBeenCalledWith(0)
+ describe('looping', function () {
+ describe('without wait', function () {
+ describe('unreversed', function () {
+ describe('nonswinging', function () {
+ it('does behave correctly at the end of an even loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(6, false)
+ runner.queue(null, spy)
+
+ runner.step(5750)
+ expect(spy).toHaveBeenCalledWith(0.75)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(1)
+ })
+
+ it('does behave correctly at the end of an uneven loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(5, false)
+ runner.queue(null, spy)
+
+ runner.step(4750)
+ expect(spy).toHaveBeenCalledWith(0.75)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(1)
+ })
+ })
+
+ describe('swinging', function () {
+ it('does behave correctly at the end of an even loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(6, true)
+ runner.queue(null, spy)
+
+ runner.step(5750)
+ expect(spy).toHaveBeenCalledWith(0.25)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(0)
+ })
+
+ it('does behave correctly at the end of an uneven loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(5, true)
+ runner.queue(null, spy)
+
+ runner.step(4750)
+ expect(spy).toHaveBeenCalledWith(0.75)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(1)
+ })
+ })
+ })
+
+ describe('reversed', function () {
+ describe('nonswinging', function () {
+ it('does behave correctly at the end of an even loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(6, false).reverse()
+ runner.queue(null, spy)
+
+ runner.step(5750)
+ expect(spy).toHaveBeenCalledWith(0.25)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(0)
+ })
+
+ it('does behave correctly at the end of an uneven loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(5, false).reverse()
+ runner.queue(null, spy)
+
+ runner.step(4750)
+ expect(spy).toHaveBeenCalledWith(0.25)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(0)
+ })
+ })
+
+ describe('swinging', function () {
+ it('does behave correctly at the end of an even loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(6, true).reverse()
+ runner.queue(null, spy)
+
+ runner.step(5750)
+ expect(spy).toHaveBeenCalledWith(0.75)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(1)
+ })
+
+ it('does behave correctly at the end of an uneven loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(5, true).reverse()
+ runner.queue(null, spy)
+
+ runner.step(4750)
+ expect(spy).toHaveBeenCalledWith(0.25)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(0)
+ })
+ })
+ })
+ })
+
+
+ describe('with wait', function () {
+ describe('unreversed', function () {
+ describe('nonswinging', function () {
+ it('does behave correctly at the end of an even loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(6, false, 100)
+ runner.queue(null, spy)
+
+ runner.step(5450)
+ expect(spy).toHaveBeenCalledWith(1)
+ spy.calls.reset()
+
+ runner.step(800)
+ expect(spy).toHaveBeenCalledWith(0.75)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(1)
+ })
+
+ it('does behave correctly at the end of an uneven loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(5, false, 100)
+ runner.queue(null, spy)
+
+ runner.step(4350)
+ expect(spy).toHaveBeenCalledWith(1)
+ spy.calls.reset()
+
+ runner.step(800)
+ expect(spy).toHaveBeenCalledWith(0.75)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(1)
+ })
+ })
+
+ describe('swinging', function () {
+ it('does behave correctly at the end of an even loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(6, true, 100)
+ runner.queue(null, spy)
+
+ runner.step(5450)
+ expect(spy).toHaveBeenCalledWith(1)
+ spy.calls.reset()
+
+ runner.step(800)
+ expect(spy).toHaveBeenCalledWith(0.25)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(0)
+ })
+
+ it('does behave correctly at the end of an uneven loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(5, true, 100)
+ runner.queue(null, spy)
+
+ runner.step(4350)
+ expect(spy).toHaveBeenCalledWith(0)
+ spy.calls.reset()
+
+ runner.step(800)
+ expect(spy).toHaveBeenCalledWith(0.75)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(1)
+ })
+ })
+ })
+
+ describe('reversed', function () {
+ describe('nonswinging', function () {
+ it('does behave correctly at the end of an even loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(6, false, 100).reverse()
+ runner.queue(null, spy)
+
+ runner.step(5450)
+ expect(spy).toHaveBeenCalledWith(0)
+ spy.calls.reset()
+
+ runner.step(800)
+ expect(spy).toHaveBeenCalledWith(0.25)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(0)
+ })
+
+ it('does behave correctly at the end of an uneven loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(5, false, 100).reverse()
+ runner.queue(null, spy)
+
+ runner.step(4350)
+ expect(spy).toHaveBeenCalledWith(0)
+ spy.calls.reset()
+
+ runner.step(800)
+ expect(spy).toHaveBeenCalledWith(0.25)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(0)
+ })
+ })
+
+ describe('swinging', function () {
+ it('does behave correctly at the end of an even loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(6, true, 100).reverse()
+ runner.queue(null, spy)
+
+ runner.step(5450)
+ expect(spy).toHaveBeenCalledWith(0)
+ spy.calls.reset()
+
+ runner.step(800)
+ expect(spy).toHaveBeenCalledWith(0.75)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(1)
+ })
+
+ it('does behave correctly at the end of an uneven loop', function () {
+ var spy = jasmine.createSpy('stepper')
+ var runner = new SVG.Runner(1000).loop(5, true, 100).reverse()
+ runner.queue(null, spy)
+
+ runner.step(4350)
+ expect(spy).toHaveBeenCalledWith(1)
+ spy.calls.reset()
+
+ runner.step(800)
+ expect(spy).toHaveBeenCalledWith(0.25)
+ runner.step(250)
+ expect(spy).toHaveBeenCalledWith(0)
+ })
+ })
+ })
+ })
})
+
+
})
+
describe('active()', function () {
it('acts as a getter without parameters', function () {
var runner = new SVG.Runner()