index.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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(StateMachine) {
  10. test("state machine included using require.js", function() {
  11. var fsm = StateMachine.create({
  12. initial: 'green',
  13. events: [
  14. { name: 'warn', from: 'green', to: 'yellow' },
  15. { name: 'panic', from: 'yellow', to: 'red' },
  16. { name: 'calm', from: 'red', to: 'yellow' },
  17. { name: 'clear', from: 'yellow', to: 'green' }
  18. ]});
  19. equal(fsm.current, 'green', "initial state should be green");
  20. fsm.warn(); equal(fsm.current, 'yellow', "warn event should transition from green to yellow");
  21. fsm.panic(); equal(fsm.current, 'red', "panic event should transition from yellow to red");
  22. fsm.calm(); equal(fsm.current, 'yellow', "calm event should transition from red to yellow");
  23. fsm.clear(); equal(fsm.current, 'green', "clear event should transition from yellow to green");
  24. });
  25. });
  26. </script>
  27. </head>
  28. <body class="flora">
  29. <h1 id="qunit-header">QUnit Test Suite</h1>
  30. <h2 id="qunit-banner"></h2>
  31. <div id="qunit-testrunner-toolbar"></div>
  32. <h2 id="qunit-userAgent"></h2>
  33. <ol id="qunit-tests"></ol>
  34. <div id="qunit-fixture">test markup</div>
  35. </body>
  36. </html>