summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorRémi Tétreault <tetreault.remi@gmail.com>2017-02-25 16:47:47 -0500
committerRémi Tétreault <tetreault.remi@gmail.com>2017-02-25 16:59:55 -0500
commit16c7266b7f60362be5fc176614b77072a1b3e3f0 (patch)
tree360153b69f741420403cf0a7b0f8e770a66ab174 /spec
parentc1736e683178a7b03fa70044c5fa69384ba560d0 (diff)
downloadsvg.js-16c7266b7f60362be5fc176614b77072a1b3e3f0.tar.gz
svg.js-16c7266b7f60362be5fc176614b77072a1b3e3f0.zip
Add tests for the animate method of the FX module
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/fx.js44
1 files changed, 44 insertions, 0 deletions
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)