Skip to content

Commit 2436aa4

Browse files
author
Mario Schuettel
committed
simplified unit test TestCmdSetColor.js
1 parent 2409f3e commit 2436aa4

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

test/unit/editor/TestCmdSetColor.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,33 @@ module( "CmdSetColor" );
33
test("Test CmdSetColor (Undo and Redo)", function() {
44

55
var editor = new Editor();
6-
7-
var object = aPointlight( "The light Light" );
6+
var pointLight = aPointlight( "The light Light" );
7+
editor.execute( new CmdAddObject( pointLight ) );
88

99
var green = 12581843; // bffbd3
1010
var blue = 14152447; // d7f2ff
1111
var yellow = 16775383; // fff8d7
1212

13-
editor.execute( new CmdAddObject( object ) );
13+
var colors = [ green, blue, yellow ];
1414

15-
// set color to green
16-
var cmd = new CmdSetColor( object, 'color', green );
17-
cmd.updatable = false; // Because otherwise the commands are merged into one command
18-
editor.execute( cmd );
19-
ok( object.color.getHex() == green , "OK, color has been set successfully, Expected: '" + green + "', Actual: '" + object.color.getHex() + "'" );
15+
colors.map( function( color ) {
2016

21-
// set color to blue
22-
var cmd = new CmdSetColor( object, 'color', blue );
23-
cmd.updatable = false; // Because otherwise the commands are merged into one command
24-
editor.execute( cmd );
25-
ok( object.color.getHex() == blue , "OK, color has been set successfully, Expected: '" + blue + "', Actual: '" + object.color.getHex() + "'" );
17+
var cmd = new CmdSetColor( pointLight, 'color', color );
18+
cmd.updatable = false;
19+
editor.execute( cmd );
2620

27-
// set color to yellow
28-
var cmd = new CmdSetColor( object, 'color', yellow );
29-
cmd.updatable = false; // Because otherwise the commands are merged into one command
30-
editor.execute( cmd );
31-
ok( object.color.getHex() == yellow , "OK, color has been set successfully, Expected: '" + yellow + "', Actual: '" + object.color.getHex() + "'" );
21+
});
3222

23+
ok( pointLight.color.getHex() == colors[ colors.length - 1 ],
24+
"OK, color has been set successfully (expected: '" + colors[ colors.length - 1 ] + "', actual: '" + pointLight.color.getHex() + "')" );
3325

3426
editor.undo();
35-
ok( object.color.getHex() == blue, "OK, changing color has been undone, Expected: '" + blue + "', Actual: '" + object.color.getHex() + "'" );
27+
ok( pointLight.color.getHex() == colors[ colors.length - 2 ],
28+
"OK, color has been set successfully after undo (expected: '" + colors[ colors.length - 2 ] + "', actual: '" + pointLight.color.getHex() + "')" );
3629

3730
editor.redo();
38-
ok( object.color.getHex() == yellow , "OK, changing color has been redone, Expected: '" + yellow + "', Actual: '" + object.color.getHex() + "'" );
31+
ok( pointLight.color.getHex() == colors[ colors.length - 1 ],
32+
"OK, color has been set successfully after redo (expected: '" + colors[ colors.length - 1 ] + "', actual: '" + pointLight.color.getHex() + "')" );
33+
3934

4035
});

0 commit comments

Comments
 (0)