SetUuidCommand.tests.js 938 B

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