From 927aeaeafa4e3bf21390b86f1a5087b49558db49 Mon Sep 17 00:00:00 2001 From: Rémi Tétreault Date: Sat, 4 Mar 2017 18:50:38 -0500 Subject: Have stop be called after each test of the fx module This change should prevent some animations to keep running in the background while the tests that spawned them is long done. Introducing this change made some tests fail, they were also fixed. --- spec/spec/fx.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'spec') diff --git a/spec/spec/fx.js b/spec/spec/fx.js index a1106cb..da09cc6 100644 --- a/spec/spec/fx.js +++ b/spec/spec/fx.js @@ -11,6 +11,8 @@ describe('FX', function() { afterEach(function() { jasmine.clock().uninstall() + + fx.stop(false, true) }) @@ -970,7 +972,12 @@ describe('FX', function() { it('when the first element of the queue is a function, it should execute it', function() { var called = false - fx.queue(function(){ called=true; expect(this).toBe(fx) }).dequeue() + fx.queue(function(){ + called = true + expect(this).toBe(fx) + this.dequeue() + }).dequeue() + expect(called).toBe(true) }) @@ -2201,17 +2208,17 @@ describe('FX', function() { describe('add()', function() { it('adds to animations obj by default', function() { - fx.add('x', 20) - expect(fx.situation.animations.x).toBe(20) + fx.add('x', new SVG.Number(20)) + expect(fx.situation.animations.x.value).toBe(20) }) it('adds to specified obj', function() { - fx.add('x', 20, 'animations') - fx.add('x', 20, 'attrs') - fx.add('x', 20, 'styles') - expect(fx.situation.animations.x).toBe(20) - expect(fx.situation.attrs.x).toBe(20) - expect(fx.situation.styles.x).toBe(20) + fx.add('x', new SVG.Number(20), 'animations') + fx.add('x', new SVG.Number(20), 'attrs') + fx.add('x', new SVG.Number(20), 'styles') + expect(fx.situation.animations.x.value).toBe(20) + expect(fx.situation.attrs.x.value).toBe(20) + expect(fx.situation.styles.x.value).toBe(20) }) }) @@ -2444,7 +2451,7 @@ describe('FX', function() { expect(fx.add).not.toHaveBeenCalled() }) }) - + describe('transform()', function() { it('returns itself when no valid transformation was found', function() { expect(fx.transform({})).toBe(fx) @@ -2625,4 +2632,4 @@ describe('SVG.MorphObj', function() { expect(obj.valueOf()).toBe('Hello') expect(obj + 'World').toBe('HelloWorld') }) -}) \ No newline at end of file +}) -- cgit v1.2.3