TestNegativeCases.js 1.7 KB

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