NegativeCases.tests.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. QUnit.module( "NegativeCases" );
  2. QUnit.test( "Test unwanted situations ", function( assert ) {
  3. var editor = new Editor();
  4. // illegal
  5. editor.undo();
  6. assert.ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" );
  7. assert.ok( editor.history.redos.length == 0, "OK, (illegal) undo did not affect the redo history" );
  8. // illegal
  9. editor.redo();
  10. assert.ok( editor.history.undos.length == 0, "OK, (illegal) redo did not affect the undo history" );
  11. assert.ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" );
  12. var box = aBox();
  13. var cmd = new AddObjectCommand( box );
  14. cmd.updatable = false;
  15. editor.execute( cmd );
  16. assert.ok( editor.history.undos.length == 1, "OK, execute changed undo history" );
  17. assert.ok( editor.history.redos.length == 0, "OK, execute did not change redo history" );
  18. // illegal
  19. editor.redo();
  20. assert.ok( editor.history.undos.length == 1, "OK, (illegal) redo did not affect the undo history" );
  21. assert.ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" );
  22. editor.undo();
  23. assert.ok( editor.history.undos.length == 0, "OK, undo changed the undo history" );
  24. assert.ok( editor.history.redos.length == 1, "OK, undo changed the redo history" );
  25. // illegal
  26. editor.undo();
  27. assert.ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" );
  28. assert.ok( editor.history.redos.length == 1, "OK, (illegal) undo did not affect the redo history" );
  29. editor.redo();
  30. assert.ok( editor.history.undos.length == 1, "OK, redo changed the undo history" );
  31. assert.ok( editor.history.redos.length == 0, "OK, undo changed the redo history" );
  32. // illegal
  33. editor.redo();
  34. assert.ok( editor.history.undos.length == 1, "OK, (illegal) did not affect the undo history" );
  35. assert.ok( editor.history.redos.length == 0, "OK, (illegal) did not affect the redo history" );
  36. } );