SetScaleCommand.tests.js 1.5 KB

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