TestNegativeCases.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * @author lxxxvi / https://github.com/lxxxvi
  3. * Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
  4. */
  5. module( "NegativeCases" );
  6. test( "Test unwanted situations ", function() {
  7. var editor = new Editor();
  8. // illegal
  9. editor.undo();
  10. ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" );
  11. ok( editor.history.redos.length == 0, "OK, (illegal) undo did not affect the redo history" );
  12. // illegal
  13. editor.redo();
  14. ok( editor.history.undos.length == 0, "OK, (illegal) redo did not affect the undo history" );
  15. ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" );
  16. var box = aBox();
  17. var cmd = new AddObjectCommand( box );
  18. cmd.updatable = false;
  19. editor.execute( cmd );
  20. ok( editor.history.undos.length == 1, "OK, execute changed undo history" );
  21. ok( editor.history.redos.length == 0, "OK, execute did not change redo history" );
  22. // illegal
  23. editor.redo();
  24. ok( editor.history.undos.length == 1, "OK, (illegal) redo did not affect the undo history" );
  25. ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" );
  26. editor.undo();
  27. ok( editor.history.undos.length == 0, "OK, undo changed the undo history" );
  28. ok( editor.history.redos.length == 1, "OK, undo changed the redo history" );
  29. // illegal
  30. editor.undo();
  31. ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" );
  32. ok( editor.history.redos.length == 1, "OK, (illegal) undo did not affect the redo history" );
  33. editor.redo();
  34. ok( editor.history.undos.length == 1, "OK, redo changed the undo history" );
  35. ok( editor.history.redos.length == 0, "OK, undo changed the redo history" );
  36. // illegal
  37. editor.redo();
  38. ok( editor.history.undos.length == 1, "OK, (illegal) did not affect the undo history" );
  39. ok( editor.history.redos.length == 0, "OK, (illegal) did not affect the redo history" );
  40. } );