TestSetColorCommand.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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( "SetColorCommand" );
  6. test( "Test SetColorCommand (Undo and Redo)", function() {
  7. var editor = new Editor();
  8. var pointLight = aPointlight( "The light Light" );
  9. editor.execute( new AddObjectCommand( pointLight ) );
  10. var green = 12581843; // bffbd3
  11. var blue = 14152447; // d7f2ff
  12. var yellow = 16775383; // fff8d7
  13. var colors = [ green, blue, yellow ];
  14. colors.map( function( color ) {
  15. var cmd = new SetColorCommand( pointLight, 'color', color );
  16. cmd.updatable = false;
  17. editor.execute( cmd );
  18. } );
  19. ok( pointLight.color.getHex() == colors[ colors.length - 1 ],
  20. "OK, color has been set successfully (expected: '" + colors[ colors.length - 1 ] + "', actual: '" + pointLight.color.getHex() + "')" );
  21. editor.undo();
  22. ok( pointLight.color.getHex() == colors[ colors.length - 2 ],
  23. "OK, color has been set successfully after undo (expected: '" + colors[ colors.length - 2 ] + "', actual: '" + pointLight.color.getHex() + "')" );
  24. editor.redo();
  25. ok( pointLight.color.getHex() == colors[ colors.length - 1 ],
  26. "OK, color has been set successfully after redo (expected: '" + colors[ colors.length - 1 ] + "', actual: '" + pointLight.color.getHex() + "')" );
  27. } );