From 16c7266b7f60362be5fc176614b77072a1b3e3f0 Mon Sep 17 00:00:00 2001 From: Rémi Tétreault Date: Sat, 25 Feb 2017 16:47:47 -0500 Subject: Add tests for the animate method of the FX module --- spec/spec/fx.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'spec') diff --git a/spec/spec/fx.js b/spec/spec/fx.js index abc49fd..ff00ecc 100644 --- a/spec/spec/fx.js +++ b/spec/spec/fx.js @@ -37,6 +37,50 @@ describe('FX', function() { expect(fx.situation.once).toEqual({}) }) + describe('animate()', function () { + it('set duration, ease and delay of the new situation to their default value when they are not passed', function() { + var defaultDuration = 1000 + , defaultEase = SVG.easing['-'] + , defaultDelay = 0 + , lastSituation = fx.animate().last() + + expect(lastSituation.duration).toBe(defaultDuration) + expect(lastSituation.ease).toBe(defaultEase) + expect(lastSituation.delay).toBe(defaultDelay) + }) + + it('use the passed values to set duration, ease and delay of the new situation', function() { + var duration = 14502 + , ease = '>' + , delay = 450 + , lastSituation = fx.animate(duration, ease, delay).last() + + expect(lastSituation.duration).toBe(duration) + expect(lastSituation.ease).toBe(SVG.easing[ease]) + expect(lastSituation.delay).toBe(delay) + }) + + it('allow duration, ease and delay to be passed in an object', function() { + var o = { + duration: 7892 + , ease: '<' + , delay: 1145 + } + , lastSituation = fx.animate(o).last() + + expect(lastSituation.duration).toBe(o.duration) + expect(lastSituation.ease).toBe(SVG.easing[o.ease]) + expect(lastSituation.delay).toBe(o.delay) + }) + + it('allow ease to be a custom function', function () { + var customEase = function() {} + , lastSituation = fx.animate({ease: customEase}).last() + + expect(lastSituation.ease).toBe(customEase) + }) + }) + describe('target()', function(){ it('returns the current fx object with no argument given', function(){ expect(fx.target()).toBe(rect) -- cgit v1.2.3