-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhanced Ki.State.plugin feature so that it can optionally be provide…
…d hash objects that get added to a plugged-in state upon creation.
- Loading branch information
Showing
3 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// ========================================================================== | ||
// Ki.Statechart Unit Test | ||
// ========================================================================== | ||
/*globals Ki TestState */ | ||
|
||
TestState = null; | ||
var obj, MixinA, MixinB, stateA, stateB, stateC; | ||
|
||
module("Ki.State.plugin: Mixin Tests", { | ||
setup: function() { | ||
|
||
MixinA = { | ||
isMixinA: YES | ||
}; | ||
|
||
MixinB = { | ||
isMixinB: YES | ||
}; | ||
|
||
TestState = Ki.State.extend({ | ||
isTestState: YES | ||
}); | ||
|
||
obj = SC.Object.create(Ki.StatechartManager, { | ||
|
||
initialState: 'stateA', | ||
|
||
stateA: Ki.State.plugin('TestState'), | ||
|
||
stateB: Ki.State.plugin('TestState', MixinA), | ||
|
||
stateC: Ki.State.plugin('TestState', MixinA, MixinB) | ||
|
||
}); | ||
|
||
stateA = obj.getState('stateA'); | ||
stateB = obj.getState('stateB'); | ||
stateC = obj.getState('stateC'); | ||
|
||
}, | ||
|
||
teardown: function() { | ||
obj = TestState = MixinA = MixinB = null; | ||
stateA = stateB = stateC = null; | ||
} | ||
|
||
}); | ||
|
||
test("check plugin state A", function() { | ||
ok(SC.kindOf(stateA, TestState)); | ||
ok(stateA.get('isTestState')); | ||
ok(!stateA.get('isMixinA')); | ||
ok(!stateA.get('isMixinB')); | ||
}); | ||
|
||
test("check plugin state B", function() { | ||
ok(SC.kindOf(stateB, TestState)); | ||
ok(stateB.get('isTestState')); | ||
ok(stateB.get('isMixinA')); | ||
ok(!stateB.get('isMixinB')); | ||
}); | ||
|
||
test("check plugin state C", function() { | ||
ok(SC.kindOf(stateC, TestState)); | ||
ok(stateC.get('isTestState')); | ||
ok(stateC.get('isMixinA')); | ||
ok(stateC.get('isMixinB')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters