Permalink
Browse files

Merge pull request #391 from koenbok/feature/defaults-fix

Fix Framer.resetDefaults
  • Loading branch information...
koenbok committed Aug 1, 2016
2 parents 9cf0155 + 7a8790a commit 5ee40e208bbd6b936a825eca6708b4a614490f3f
Showing with 31 additions and 12 deletions.
  1. +2 −3 framer/Defaults.coffee
  2. +9 −3 test/tests.coffee
  3. +20 −6 test/tests/LayerTest.coffee
View
@@ -87,8 +87,7 @@ exports.Defaults =
options = _.clone options
# Always start with the originals
defaults = _.clone Originals[className]
defaults = _.cloneDeep Originals[className]
# Copy over the user defined options
for k, v of Framer.Defaults[className]
defaults[k] = if _.isFunction(v) then v() else v
@@ -114,4 +113,4 @@ exports.Defaults =
exports.Defaults.reset()
reset: ->
window.Framer.Defaults = _.clone Originals
window.Framer.Defaults = _.cloneDeep Originals
View
@@ -1,8 +1,14 @@
window.chai = require("chai")
# We don't want to update all the tests if we change these
Framer.Defaults.Layer.width = 100
Framer.Defaults.Layer.height = 100
previousReset = Framer.resetDefaults
Framer.resetDefaults = ->
previousReset()
# We don't want to update all the tests if we change these
Framer.Defaults.Layer.width = 100
Framer.Defaults.Layer.height = 100
Framer.resetDefaults()
window.console.debug = (v) ->
window.console.warn = (v) ->
@@ -11,22 +11,36 @@ describe "Layer", ->
describe "Defaults", ->
it "should set defaults", ->
it "should reset nested defaults", ->
Framer.Defaults.DeviceComponent.animationOptions.curve = "spring"
Framer.resetDefaults()
Framer.Defaults.DeviceComponent.animationOptions.curve.should.equal "ease-in-out"
it "should reset width and height to their previous values", ->
previousWidth = Framer.Defaults.Layer.width
previousHeight = Framer.Defaults.Layer.height
Framer.Defaults.Layer.width = 123
Framer.Defaults.Layer.height = 123
Framer.resetDefaults()
Framer.Defaults.Layer.width.should.equal previousWidth
Framer.Defaults.Layer.height.should.equal previousHeight
it "should set defaults", ->
width = Utils.randomNumber(0,400)
height = Utils.randomNumber(0,400)
Framer.Defaults =
Layer:
width: 200
height: 200
width: width
height: height
layer = new Layer()
layer.width.should.equal 200
layer.height.should.equal 200
layer.width.should.equal width
layer.height.should.equal height
Framer.resetDefaults()
layer = new Layer()
layer.width.should.equal 100
layer.height.should.equal 100

0 comments on commit 5ee40e2

Please sign in to comment.