diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-05-24 20:26:59 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-05-24 20:26:59 +0200 |
commit | ebf2a8bb395b78b5bc513fb1ec17e1222dcb0f1d (patch) | |
tree | 6cced8924164559a2e55afc03967e09f19a036f9 /spec | |
parent | 70a8fd5fac29d5eb3a65dbee32d1a3fa817523bf (diff) | |
download | svg.js-ebf2a8bb395b78b5bc513fb1ec17e1222dcb0f1d.tar.gz svg.js-ebf2a8bb395b78b5bc513fb1ec17e1222dcb0f1d.zip |
go through specs and make fixes where needed
Diffstat (limited to 'spec')
-rw-r--r-- | spec/SpecRunner.html | 14 | ||||
-rw-r--r-- | spec/spec/morphing.js | 14 | ||||
-rw-r--r-- | spec/spec/runner.js | 48 |
3 files changed, 38 insertions, 38 deletions
diff --git a/spec/SpecRunner.html b/spec/SpecRunner.html index 7c69811..5e70186 100644 --- a/spec/SpecRunner.html +++ b/spec/SpecRunner.html @@ -16,7 +16,10 @@ <!-- include source files here... --> <script src="../dist/svg.js" charset="utf-8"></script> + <script src="../src/controller.js" charset="utf-8"></script> <script src="../src/morph.js" charset="utf-8"></script> + <script src="../src/runner.js" charset="utf-8"></script> + <script src="../src/timeline.js" charset="utf-8"></script> </head> @@ -99,13 +102,8 @@ <script src="spec/utils.js"></script> <script src="spec/viewbox.js"></script> --> - <script src="spec/morphing.js"></script> - - - - - - - <script src="spec/animator.js"></script> + <!-- <script src="spec/morphing.js"></script> + <script src="spec/animator.js"></script> --> + <script src="spec/runner.js"></script> </body> </html> diff --git a/spec/spec/morphing.js b/spec/spec/morphing.js index 1bc2cd6..63a6cf2 100644 --- a/spec/spec/morphing.js +++ b/spec/spec/morphing.js @@ -1,6 +1,4 @@ describe('Morphing', function () { - var morphing - describe('constructors', function () { it('SVG.Morphable with Number', function () { @@ -128,36 +126,36 @@ describe('Morphing', function () { describe('from()', function () { it('sets the type of the runner', function () { var morpher = new SVG.Morphable().from(5) - expect(this.type()).toBe(SVG.Number) + expect(morpher.type()).toBe(SVG.Number) }) it('sets the from attribute to an array representation of the morphable type', function () { var morpher = new SVG.Morphable().from(5) - expect(this.from()).toEqual(jasmine.arrayContaining([5])) + expect(morpher.from()).toEqual(jasmine.arrayContaining([5])) }) }) describe('type()', function () { it('sets the type of the runner', function () { var morpher = new SVG.Morphable().type(SVG.Number) - expect(this._type).toBe(SVG.Number) + expect(morpher._type).toBe(SVG.Number) }) it('gets the type of the runner', function () { var morpher = new SVG.Morphable().type(SVG.Number) - expect(this.type()).toBe(SVG.Number) + expect(morpher.type()).toBe(SVG.Number) }) }) describe('to()', function () { it('sets the type of the runner', function () { var morpher = new SVG.Morphable().to(5) - expect(this.type()).toBe(SVG.Number) + expect(morpher.type()).toBe(SVG.Number) }) it('sets the from attribute to an array representation of the morphable type', function () { var morpher = new SVG.Morphable().to(5) - expect(this.to()).toEqual(jasmine.arrayContaining([5])) + expect(morpher.to()).toEqual(jasmine.arrayContaining([5])) }) }) }) diff --git a/spec/spec/runner.js b/spec/spec/runner.js index e63c751..b09cd43 100644 --- a/spec/spec/runner.js +++ b/spec/spec/runner.js @@ -3,36 +3,41 @@ describe('SVG.Runner', function () { var initFn = jasmine.createSpy('initFn') var runFn = jasmine.createSpy('runFn') + beforeEach(function () { + initFn.calls.reset() + runFn.calls.reset() + }) + describe('())', function () { it('creates a runner with defaults', function () { var runner = new SVG.Runner() expect(runner instanceof SVG.Runner).toBe(true) - expect(runner._duration).toBe(SVG.timeline.duration) - expect(runner._ease).toBe(SVG.timeline.ease) - expect(runner._stepper).toBe(null) + expect(runner._duration).toBe(SVG.defaults.timeline.duration) + expect(runner._stepper instanceof SVG.Ease).toBe(true) }) it('creates a runner with duration set', function () { var runner = new SVG.Runner(1000) expect(runner instanceof SVG.Runner).toBe(true) expect(runner._duration).toBe(1000) - expect(runner._ease).toBe(SVG.timeline.ease) - expect(runner._stepper).toBe(null) + expect(runner._stepper instanceof SVG.Ease).toBe(true) }) it('creates a runner with controller set', function () { var runner = new SVG.Runner(runFn) expect(runner instanceof SVG.Runner).toBe(true) - expect(runner._duration).toBe(null) - expect(runner._ease).toBe(SVG.timeline.ease) - expect(runner._stepper).toBe(runFn) + expect(runner._duration).toBeFalsy() + expect(runner._stepper instanceof SVG.Controller).toBe(true) }) }) describe('constructors', function () { describe('animate()', function () { it('creates a runner with the element set and schedules it on the timeline', function () { - spyOn(SVG, 'Runner').and.callTrough() + var orginalRunner = SVG.Runner + spyOn(SVG, 'Runner').and.callFake(function() { + return new orginalRunner() + }) var element = SVG('<rect>') var runner = element.animate() @@ -49,10 +54,8 @@ describe('SVG.Runner', function () { spyOn(element, 'animate') element.loop() - expect(element.animate).toHaveBeenCalledWith(objectContaining({ - duration: SVG.defaults.timeline.duration, - times: Infinity, - swing: false + expect(element.animate).toHaveBeenCalledWith(jasmine.objectContaining({ + times: Infinity })); }) }) @@ -73,7 +76,7 @@ describe('SVG.Runner', function () { var runner = new SVG.Runner() runner.queue(initFn, runFn, true) - expect(runner.functions[0]).toEqual(jasmine.objectContaining({ + expect(runner._functions[0]).toEqual(jasmine.objectContaining({ alwaysInitialise: true, initialiser: initFn, runner: runFn @@ -106,6 +109,7 @@ describe('SVG.Runner', function () { }) describe('step()', function () { + it('calls initFn once and runFn at every step when alwaysInitialise is false', function() { var runner = new SVG.Runner() runner.queue(initFn, runFn, false) @@ -115,7 +119,7 @@ describe('SVG.Runner', function () { expect(runFn).toHaveBeenCalled() runner.step() - expect(init.calls.count()).toBe(1) + expect(initFn.calls.count()).toBe(1) expect(runFn.calls.count()).toBe(2) }) @@ -143,7 +147,7 @@ describe('SVG.Runner', function () { var runner = new SVG.Runner() runner.queue(initFn, runFn, false) - expect(runner.step()).toBe(true) + expect(runner.step(SVG.defaults.timeline.duration)).toBe(true) }) }) @@ -201,7 +205,7 @@ describe('SVG.Runner', function () { var element = SVG('<rect>') var runner2 = element.animate() - expect(runner1.element()).toBe(element) + expect(runner2.element()).toBe(element) }) it('sets an element to be bound to the runner', function () { @@ -220,10 +224,10 @@ describe('SVG.Runner', function () { it('calls queue giving only a function to call on every step', function () { var runner = new SVG.Runner() - spyOn(runner.queue) + spyOn(runner, 'queue') runner.during(runFn) - expect(runner.queue).toHaveBeenCalledWith(null, runFn) + expect(runner.queue).toHaveBeenCalledWith(null, runFn, false) }) }) @@ -235,7 +239,7 @@ describe('SVG.Runner', function () { it('calls step with Infinity as arument', function () { var runner = new SVG.Runner() - spyOn(runner.step) + spyOn(runner, 'step') runner.finish() expect(runner.step).toHaveBeenCalledWith(Infinity) @@ -250,7 +254,7 @@ describe('SVG.Runner', function () { it('reverses the runner by setting the time to the end and going backwards', function () { var runner = new SVG.Runner() - spyOn(runner.time) + spyOn(runner, 'time') runner.reverse() expect(runner.time).toHaveBeenCalledWith(SVG.defaults.timeline.duration) @@ -267,7 +271,7 @@ describe('SVG.Runner', function () { var runner = new SVG.Runner() runner.ease(function () {}) - expect(runner._stepper instanceof SVG.Stepper).toBe(true) + expect(runner._stepper instanceof SVG.Ease).toBe(true) }) }) }) |