Permalink
Browse files

Reset when adding multiple states

  • Loading branch information...
nvh committed Jul 26, 2016
1 parent 7179178 commit 68fc9ba2ede34bc8884d4ac8f6389cad8baca136
Showing with 23 additions and 0 deletions.
  1. +1 −0 framer/Layer.coffee
  2. +22 −0 test/tests/LayerStatesTest.coffee
View
@@ -1010,6 +1010,7 @@ class exports.Layer extends BaseClass
importable: false
get: -> @_stateMachine.states
set: (states) ->
+ @_stateMachine.reset()
for name,state of states
@_stateMachine.states[name] = state
@@ -56,6 +56,28 @@ describe "LayerStates", ->
Framer.resetDefaults()
+ describe "Adding", ->
+ describe "when setting multiple states", ->
+ it "should override existing states", ->
+ layer = new Layer
+ layer.states.test = x: 100
+ layer.states =
+ stateA: x:200
+ stateB: scale: 0.5
+ assert.deepEqual layer.stateNames, ['initial','stateA','stateB']
+
+ it "should reset the previous and current states", ->
+ layer = new Layer
+ layer.states.test = x: 100
+ layer.switchTo 'test'
+ layer.states =
+ stateA: x:200
+ stateB: scale: 0.5
+ assert.equal layer.states.previousName, null
+ layer.states.currentName.should.equal 'initial'
+
+
+
describe "Switch", ->

0 comments on commit 68fc9ba

Please sign in to comment.