|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <title>Finite State Machine Tests - USING REQUIREJS INCLUDE MECHANISM</title> |
| 5 | + <link rel="stylesheet" href="../qunit/qunit.css" media="screen"> |
| 6 | + <script src="../qunit/qunit.js"></script> |
| 7 | + <script src="require.js"></script> |
| 8 | + <script> |
| 9 | + require(["../../state-machine.js"], function(RequiredStateMachine) { |
| 10 | + |
| 11 | + module("require.js"); |
| 12 | + |
| 13 | + test("state machine included using require.js with custom name", function() { |
| 14 | + |
| 15 | + var fsm = RequiredStateMachine.create({ |
| 16 | + initial: 'green', |
| 17 | + events: [ |
| 18 | + { name: 'warn', from: 'green', to: 'yellow' }, |
| 19 | + { name: 'panic', from: 'yellow', to: 'red' }, |
| 20 | + { name: 'calm', from: 'red', to: 'yellow' }, |
| 21 | + { name: 'clear', from: 'yellow', to: 'green' } |
| 22 | + ]}); |
| 23 | + |
| 24 | + equals(fsm.current, 'green', "initial state should be green"); |
| 25 | + |
| 26 | + fsm.warn(); equals(fsm.current, 'yellow', "warn event should transition from green to yellow"); |
| 27 | + fsm.panic(); equals(fsm.current, 'red', "panic event should transition from yellow to red"); |
| 28 | + fsm.calm(); equals(fsm.current, 'yellow', "calm event should transition from red to yellow"); |
| 29 | + fsm.clear(); equals(fsm.current, 'green', "clear event should transition from yellow to green"); |
| 30 | + |
| 31 | + }); |
| 32 | + |
| 33 | + }); |
| 34 | + </script> |
| 35 | +</head> |
| 36 | +<body class="flora"> |
| 37 | + <h1 id="qunit-header">QUnit Test Suite</h1> |
| 38 | + <h2 id="qunit-banner"></h2> |
| 39 | + <div id="qunit-testrunner-toolbar"></div> |
| 40 | + <h2 id="qunit-userAgent"></h2> |
| 41 | + <ol id="qunit-tests"></ol> |
| 42 | + <div id="qunit-fixture">test markup</div> |
| 43 | + </body> |
| 44 | +</html> |
0 commit comments