TestNegativeCases.js 2.1 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. QUnit.module( "NegativeCases" );
  6. QUnit.test( "Test unwanted situations ", function( assert ) {
  7. var editor = new Editor();
  8. // illegal
  9. editor.undo();
  10. assert.ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" );
  11. assert.ok( editor.history.redos.length == 0, "OK, (illegal) undo did not affect the redo history" );
  12. // illegal
  13. editor.redo();
  14. assert.ok( editor.history.undos.length == 0, "OK, (illegal) redo did not affect the undo history" );
  15. assert.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. assert.ok( editor.history.undos.length == 1, "OK, execute changed undo history" );
  21. assert.ok( editor.history.redos.length == 0, "OK, execute did not change redo history" );
  22. // illegal
  23. editor.redo();
  24. assert.ok( editor.history.undos.length == 1, "OK, (illegal) redo did not affect the undo history" );
  25. assert.ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" );
  26. editor.undo();
  27. assert.ok( editor.history.undos.length == 0, "OK, undo changed the undo history" );
  28. assert.ok( editor.history.redos.length == 1, "OK, undo changed the redo history" );
  29. // illegal
  30. editor.undo();
  31. assert.ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" );
  32. assert.ok( editor.history.redos.length == 1, "OK, (illegal) undo did not affect the redo history" );
  33. editor.redo();
  34. assert.ok( editor.history.undos.length == 1, "OK, redo changed the undo history" );
  35. assert.ok( editor.history.redos.length == 0, "OK, undo changed the redo history" );
  36. // illegal
  37. editor.redo();
  38. assert.ok( editor.history.undos.length == 1, "OK, (illegal) did not affect the undo history" );
  39. assert.ok( editor.history.redos.length == 0, "OK, (illegal) did not affect the redo history" );
  40. } );