SetUuidCommand.tests.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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( "SetUuidCommand" );
  6. QUnit.test( "Test SetUuidCommand (Undo and Redo)", function( assert ) {
  7. var editor = new Editor();
  8. var object = aBox( 'UUID test box' );
  9. editor.execute( new AddObjectCommand( object ) );
  10. var uuids = [ THREE.Math.generateUUID(), THREE.Math.generateUUID(), THREE.Math.generateUUID() ];
  11. uuids.map( function( uuid ) {
  12. var cmd = new SetUuidCommand( object, uuid );
  13. cmd.updatable = false;
  14. editor.execute( cmd );
  15. } );
  16. assert.ok( object.uuid == uuids[ uuids.length - 1 ],
  17. "OK, UUID on actual object matches last UUID in the test data array " );
  18. editor.undo();
  19. assert.ok( object.uuid == uuids[ uuids.length - 2 ],
  20. "OK, UUID on actual object matches second to the last UUID in the test data array (after undo)" );
  21. editor.redo();
  22. assert.ok( object.uuid == uuids[ uuids.length - 1 ],
  23. "OK, UUID on actual object matches last UUID in the test data array again (after redo) " );
  24. } );