2
0

TestSetGeometryValueCommand.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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( "SetGeometryValueCommand" );
  6. test( "Test SetGeometryValueCommand (Undo and Redo)", function() {
  7. var editor = new Editor();
  8. var box = aBox( 'The Box' );
  9. var cmd = new AddObjectCommand( box );
  10. cmd.updatable = false;
  11. editor.execute( cmd );
  12. var testData = [
  13. { uuid: THREE.Math.generateUUID(), name: 'Bruno' },
  14. { uuid: THREE.Math.generateUUID(), name: 'Jack' }
  15. ];
  16. for ( var i = 0; i < testData.length; i ++ ) {
  17. var keys = Object.keys( testData[ i ] );
  18. keys.map( function( key ) {
  19. cmd = new SetGeometryValueCommand( box, key, testData[ i ][ key ] );
  20. cmd.updatable = false;
  21. editor.execute( cmd );
  22. } );
  23. }
  24. ok( box.geometry.name == testData[ 1 ].name, "OK, box.geometry.name is correct after executes" );
  25. ok( box.geometry.uuid == testData[ 1 ].uuid, "OK, box.geometry.uuid is correct after executes" );
  26. editor.undo();
  27. editor.undo();
  28. ok( box.geometry.name == testData[ 0 ].name, "OK, box.geometry.name is correct after undos" );
  29. ok( box.geometry.uuid == testData[ 0 ].uuid, "OK, box.geometry.uuid is correct after undos" );
  30. editor.redo();
  31. editor.redo();
  32. ok( box.geometry.name == testData[ 1 ].name, "OK, box.geometry.name is correct after executes" );
  33. ok( box.geometry.uuid == testData[ 1 ].uuid, "OK, box.geometry.uuid is correct after executes" );
  34. } );