12345678910111213141516171819202122232425262728293031 |
- module( "CmdSetScriptSource" );
- test( "Test CmdSetScriptSource (Undo and Redo)", function() {
- var editor = new Editor();
- var box = aBox( "The scripted box" );
- var xMove = { name: "", source: "function update( event ) { this.position.x = this.position.x + 1; }" };
- var yMove = { name: "", source: "function update( event ) { this.position.y = this.position.y + 1; }" };
- var scripts = [ xMove, yMove ];
- editor.execute( new CmdAddObject( box ) );
- var cmd = new CmdAddScript( box, scripts[0] );
- cmd.updatable = false;
- editor.execute( cmd );
- cmd = new CmdSetScriptSource( box, xMove, yMove['source'], xMove['source'], 0 );
- cmd.updatable = false;
- editor.execute( cmd );
- ok( editor.scripts[ box.uuid ][0][ 'source' ] == yMove[ 'source' ], "OK, script source has been set successfully");
- console.log( editor.scripts );
- editor.undo();
- ok( editor.scripts[ box.uuid ][0][ 'source' ] == xMove[ 'source' ], "OK, script source has been set to previous state");
- editor.redo();
- ok( editor.scripts[ box.uuid ][0][ 'source' ] == yMove[ 'source' ], "OK, script source has been reverted successfully");
- });
|