TestCmdSetValue.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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( "CmdSetValue" );
  6. test( "Test CmdSetValue (Undo and Redo)", function() {
  7. var editor = new Editor();
  8. var valueBefore = 1.10;
  9. var valueAfter = 2.20;
  10. var box = aBox( 'A Box' );
  11. var light = aPointlight( 'A PointLight' );
  12. var cam = aPerspectiveCamera( 'A PerspectiveCamera' );
  13. [ box, light, cam ].map( function( object ) {
  14. editor.execute( new CmdAddObject( object ) );
  15. ok( 0 == 0, "Testing object of type '" + object.type + "'" );
  16. [ 'name', 'fov', 'near', 'far', 'intensity', 'distance', 'angle', 'exponent', 'decay', 'visible', 'userData' ].map( function( item ) {
  17. if ( object[ item ] !== undefined ) {
  18. var cmd = new CmdSetValue( object, item, valueBefore );
  19. cmd.updatable = false;
  20. editor.execute( cmd );
  21. ok( object[ item ] == valueBefore, " OK, the attribute '" + item + "' is correct after first execute (expected: '" + valueBefore + "', actual: '" + object[ item ] + "')" );
  22. var cmd = new CmdSetValue( object, item, valueAfter );
  23. cmd.updatable = false;
  24. editor.execute( cmd );
  25. ok( object[ item ] == valueAfter, " OK, the attribute '" + item + "' is correct after second execute (expected: '" + valueAfter + "', actual: '" + object[ item ] + "')" );
  26. editor.undo();
  27. ok( object[ item ] == valueBefore, " OK, the attribute '" + item + "' is correct after undo (expected: '" + valueBefore + "', actual: '" + object[ item ] + "')" );
  28. editor.redo();
  29. ok( object[ item ] == valueAfter, " OK, the attribute '" + item + "' is correct after redo (expected: '" + valueAfter + "', actual: '" + object[ item ] + "')" );
  30. }
  31. } );
  32. } );
  33. } );