TestSetScaleCommand.js 1.5 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( "SetScaleCommand" );
  6. test( "Test SetScaleCommand (Undo and Redo)", function() {
  7. // setup
  8. var editor = new Editor();
  9. var box = aBox();
  10. editor.execute( new AddObjectCommand( box ) );
  11. // scales
  12. var scales = [
  13. { x: 1.4, y: 2.7, z: 0.4 },
  14. { x: 0.1, y: 1.3, z: 2.9 },
  15. { x: 3.2, y: 0.3, z: 2.0 }
  16. ];
  17. scales.map( function( scale ) {
  18. var newScale = new THREE.Vector3( scale.x, scale.y, scale.z );
  19. var cmd = new SetScaleCommand( box, newScale );
  20. cmd.updatable = false;
  21. editor.execute( cmd );
  22. } );
  23. ok( box.scale.x == scales[ scales.length - 1 ].x, "OK, setting X scale value was successful" );
  24. ok( box.scale.y == scales[ scales.length - 1 ].y, "OK, setting Y scale value was successful" );
  25. ok( box.scale.z == scales[ scales.length - 1 ].z, "OK, setting Z scale value was successful" );
  26. editor.undo();
  27. ok( box.scale.x == scales[ scales.length - 2 ].x, "OK, X scale is correct after undo" );
  28. ok( box.scale.y == scales[ scales.length - 2 ].y, "OK, Y scale is correct after undo" );
  29. ok( box.scale.z == scales[ scales.length - 2 ].z, "OK, Z scale is correct after undo" );
  30. editor.redo();
  31. ok( box.scale.x == scales[ scales.length - 1 ].x, "OK, X scale is correct after redo" );
  32. ok( box.scale.y == scales[ scales.length - 1 ].y, "OK, Y scale is correct after redo" );
  33. ok( box.scale.z == scales[ scales.length - 1 ].z, "OK, Z scale is correct after redo" );
  34. } );