123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Finite State Machine Tests - USING REQUIREJS INCLUDE MECHANISM</title>
- <link rel="stylesheet" href="../qunit/qunit.css" media="screen">
- <script src="../qunit/qunit.js"></script>
- <script src="require.js"></script>
- <script>
- require(["../../state-machine.js"], function(StateMachine) {
- test("state machine included using require.js", function() {
- var fsm = StateMachine.create({
- initial: 'green',
- events: [
- { name: 'warn', from: 'green', to: 'yellow' },
- { name: 'panic', from: 'yellow', to: 'red' },
- { name: 'calm', from: 'red', to: 'yellow' },
- { name: 'clear', from: 'yellow', to: 'green' }
- ]});
- equal(fsm.current, 'green', "initial state should be green");
- fsm.warn(); equal(fsm.current, 'yellow', "warn event should transition from green to yellow");
- fsm.panic(); equal(fsm.current, 'red', "panic event should transition from yellow to red");
- fsm.calm(); equal(fsm.current, 'yellow', "calm event should transition from red to yellow");
- fsm.clear(); equal(fsm.current, 'green', "clear event should transition from yellow to green");
- });
- });
- </script>
- </head>
- <body class="flora">
- <h1 id="qunit-header">QUnit Test Suite</h1>
- <h2 id="qunit-banner"></h2>
- <div id="qunit-testrunner-toolbar"></div>
- <h2 id="qunit-userAgent"></h2>
- <ol id="qunit-tests"></ol>
- <div id="qunit-fixture">test markup</div>
- </body>
- </html>
|