Skip to content

Commit 829b97d

Browse files
author
Mario Schuettel
committed
formatted code according to mrdoob codestyle
1 parent cd5d8ee commit 829b97d

24 files changed

Lines changed: 251 additions & 208 deletions

test/unit/editor/CommonUtilities.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ function mergeParams( defaults, customParams ) {
88
var params = {};
99

1010
defaultKeys.map( function( key ) {
11+
1112
params[ key ] = customParams[ key ] || defaultKeys[ key ];
12-
});
13+
14+
} );
1315

1416
return params;
1517

@@ -19,9 +21,11 @@ function mergeParams( defaults, customParams ) {
1921
function getGeometryParams( type, customParams ) {
2022

2123
if ( typeof customParams != "undefined" &&
22-
typeof customParams.geometry != "undefined" &&
23-
typeof customParams.geometry.parameters != "undefined" ) {
24+
typeof customParams.geometry != "undefined" &&
25+
typeof customParams.geometry.parameters != "undefined" ) {
26+
2427
var customGeometryParams = customParams.geometry.parameters;
28+
2529
}
2630

2731
var defaults = {};
@@ -58,24 +62,24 @@ function getGeometry( type, customParams ) {
5862
case "BoxGeometry":
5963

6064
return new THREE.BoxGeometry(
61-
params['width'],
62-
params['height'],
63-
params['depth'],
64-
params['widthSegments'],
65-
params['heightSegments'],
66-
params['depthSegments']
65+
params[ 'width' ],
66+
params[ 'height' ],
67+
params[ 'depth' ],
68+
params[ 'widthSegments' ],
69+
params[ 'heightSegments' ],
70+
params[ 'depthSegments' ]
6771
);
6872

6973
case "SphereGeometry":
7074

7175
return new THREE.SphereGeometry(
72-
params['radius'],
73-
params['widthSegments'],
74-
params['heightSegments'],
75-
params['phiStart'],
76-
params['phiLength'],
77-
params['thetaStart'],
78-
params['thetaLength']
76+
params[ 'radius' ],
77+
params[ 'widthSegments' ],
78+
params[ 'heightSegments' ],
79+
params[ 'phiStart' ],
80+
params[ 'phiLength' ],
81+
params[ 'thetaStart' ],
82+
params[ 'thetaLength' ]
7983
);
8084

8185
default:
@@ -102,6 +106,7 @@ function getObject( name, type, customParams ) {
102106
function aBox( name, customParams ) {
103107

104108
return getObject( name, "BoxGeometry", customParams );
109+
105110
}
106111

107112
function aSphere( name, customParams ) {
@@ -133,13 +138,14 @@ function getScriptCount( editor ) {
133138
var scriptsKeys = Object.keys( editor.scripts );
134139
var scriptCount = 0;
135140

136-
for ( var i = 0; i < scriptsKeys.length; i++ ) {
141+
for ( var i = 0; i < scriptsKeys.length; i ++ ) {
137142

138-
scriptCount += editor.scripts[ scriptsKeys[i] ].length;
143+
scriptCount += editor.scripts[ scriptsKeys[ i ] ].length;
139144

140145
}
141146

142147
return scriptCount;
148+
143149
}
144150

145151
function exportScene( editor ) {
@@ -159,4 +165,4 @@ function importScene( data ) {
159165

160166
return result;
161167

162-
}
168+
}

test/unit/editor/TestCmdAddObjectAndCmdRemoveObject.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
2424
ok( editor.scene.children.length == 0, "OK, adding '" + object.type + "' is undone (was removed)" );
2525

2626
editor.redo();
27-
ok( editor.scene.children[ 0 ].name == object.name , "OK, removed '" + object.type + "' was added again (redo)" );
27+
ok( editor.scene.children[ 0 ].name == object.name, "OK, removed '" + object.type + "' was added again (redo)" );
2828

2929

3030
// Test Remove
@@ -35,13 +35,13 @@ test( "Test CmdAddObject and CmdRemoveObject (Undo and Redo)", function() {
3535
ok( editor.scene.children.length == 0, "OK, removing object was successful" );
3636

3737
editor.undo();
38-
ok( editor.scene.children[ 0 ].name == object.name , "OK, removed object was added again (undo)" );
38+
ok( editor.scene.children[ 0 ].name == object.name, "OK, removed object was added again (undo)" );
3939

4040
editor.redo();
4141
ok( editor.scene.children.length == 0, "OK, object was removed again (redo)" );
4242

4343

44-
});
44+
} );
4545

4646

47-
});
47+
} );

test/unit/editor/TestCmdAddScript.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
module("CmdAddScript");
1+
module( "CmdAddScript" );
22

3-
test( "Test CmdAddScript (Undo and Redo)" , function() {
3+
test( "Test CmdAddScript (Undo and Redo)", function() {
44

55
var editor = new Editor();
66

@@ -15,14 +15,16 @@ test( "Test CmdAddScript (Undo and Redo)" , function() {
1515

1616
// add objects to editor
1717
objects.map( function( item ) {
18+
1819
editor.execute( new CmdAddObject( item ) );
19-
});
20+
21+
} );
2022
ok( editor.scene.children.length == 2, "OK, the box and the sphere have been added" );
2123

2224
// add scripts to the objects
23-
for ( var i = 0; i < scripts.length; i++ ) {
25+
for ( var i = 0; i < scripts.length; i ++ ) {
2426

25-
var cmd = new CmdAddScript( objects[i], scripts[i] );
27+
var cmd = new CmdAddScript( objects[ i ], scripts[ i ] );
2628
cmd.updatable = false;
2729
editor.execute( cmd );
2830

@@ -31,9 +33,9 @@ test( "Test CmdAddScript (Undo and Redo)" , function() {
3133
var scriptsKeys = Object.keys( editor.scripts );
3234
ok( getScriptCount( editor ) == scripts.length, "OK, correct number of scripts have been added" );
3335

34-
for ( var i = 0; i < objects.length; i++ ) {
36+
for ( var i = 0; i < objects.length; i ++ ) {
3537

36-
ok( objects[i].uuid == scriptsKeys[i], "OK, script key #" + i + " matches the object's UUID" );
38+
ok( objects[ i ].uuid == scriptsKeys[ i ], "OK, script key #" + i + " matches the object's UUID" );
3739

3840
}
3941

@@ -44,11 +46,12 @@ test( "Test CmdAddScript (Undo and Redo)" , function() {
4446
ok( getScriptCount( editor ) == scripts.length, "OK, one script has been added again by redo" );
4547

4648

47-
for (var i = 0; i < scriptsKeys.length; i++ ) {
49+
for ( var i = 0; i < scriptsKeys.length; i ++ ) {
4850

49-
ok( editor.scripts[ scriptsKeys[i] ][0] == scripts[i], "OK, script #" + i + " is still assigned correctly" );
51+
ok( editor.scripts[ scriptsKeys[ i ] ][ 0 ] == scripts[ i ], "OK, script #" + i + " is still assigned correctly" );
5052

5153
}
5254

5355

54-
});
56+
} );
57+

test/unit/editor/TestCmdMoveObject.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ test( "Test CmdMoveObject (Undo and Redo)", function() {
1414
editor.execute( new CmdAddObject( lukeSkywalker ) );
1515

1616

17-
ok( anakinSkywalker.parent.name == "Scene", "OK, Anakin's parent is 'Scene' ");
18-
ok( lukeSkywalker.parent.name == "Scene", "OK, Luke's parent is 'Scene' ");
17+
ok( anakinSkywalker.parent.name == "Scene", "OK, Anakin's parent is 'Scene' " );
18+
ok( lukeSkywalker.parent.name == "Scene", "OK, Luke's parent is 'Scene' " );
1919

2020
// Tell Luke, Anakin is his father
2121
editor.execute( new CmdMoveObject( lukeSkywalker, anakinSkywalker ) );
2222

23-
ok( true === true, "(Luke has been told who his father is)");
24-
ok( anakinSkywalker.parent.name == "Scene" , "OK, Anakin's parent is still 'Scene' ");
25-
ok( lukeSkywalker.parent.name == anakinsName, "OK, Luke's parent is '" + anakinsName + "' ");
23+
ok( true === true, "(Luke has been told who his father is)" );
24+
ok( anakinSkywalker.parent.name == "Scene", "OK, Anakin's parent is still 'Scene' " );
25+
ok( lukeSkywalker.parent.name == anakinsName, "OK, Luke's parent is '" + anakinsName + "' " );
2626

2727
editor.undo();
28-
ok( true === true, "(Statement undone)");
29-
ok( anakinSkywalker.parent.name == "Scene", "OK, Anakin's parent is still 'Scene' ");
30-
ok( lukeSkywalker.parent.name == "Scene", "OK, Luke's parent is 'Scene' again ");
28+
ok( true === true, "(Statement undone)" );
29+
ok( anakinSkywalker.parent.name == "Scene", "OK, Anakin's parent is still 'Scene' " );
30+
ok( lukeSkywalker.parent.name == "Scene", "OK, Luke's parent is 'Scene' again " );
3131

3232
editor.redo();
33-
ok( true === true, "(Statement redone)");
34-
ok( anakinSkywalker.parent.name == "Scene" , "OK, Anakin's parent is still 'Scene' ");
35-
ok( lukeSkywalker.parent.name == anakinsName, "OK, Luke's parent is '" + anakinsName + "' again ");
33+
ok( true === true, "(Statement redone)" );
34+
ok( anakinSkywalker.parent.name == "Scene", "OK, Anakin's parent is still 'Scene' " );
35+
ok( lukeSkywalker.parent.name == anakinsName, "OK, Luke's parent is '" + anakinsName + "' again " );
3636

37-
});
37+
} );

test/unit/editor/TestCmdMultiCmds.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
1414

1515
// setup first multi commands
1616
var firstMultiCmds = [
17-
new CmdSetGeometry( box, boxGeometries[0] ),
17+
18+
new CmdSetGeometry( box, boxGeometries[ 0 ] ),
1819
new CmdSetPosition( box, new THREE.Vector3( 1, 2, 3 ) ),
1920
new CmdSetRotation( box, new THREE.Euler( 0.1, 0.2, 0.2 ) ),
2021
new CmdSetScale( box, new THREE.Vector3( 1.1, 1.2, 1.3 ) )
22+
2123
];
24+
2225
firstMultiCmds.map( function( cmd ) {
26+
2327
cmd.updatable = false;
24-
});
28+
29+
} );
2530

2631
var firstMultiCmd = new CmdMultiCmds( firstMultiCmds );
2732
firstMultiCmd.updatable = false;
@@ -30,14 +35,19 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
3035

3136
// setup second multi commands
3237
var secondMultiCmds = [
33-
new CmdSetGeometry( box, boxGeometries[1] ),
38+
39+
new CmdSetGeometry( box, boxGeometries[ 1 ] ),
3440
new CmdSetPosition( box, new THREE.Vector3( 4, 5, 6 ) ),
3541
new CmdSetRotation( box, new THREE.Euler( 0.4, 0.5, 0.6 ) ),
3642
new CmdSetScale( box, new THREE.Vector3( 1.4, 1.5, 1.6 ) )
43+
3744
];
45+
3846
secondMultiCmds.map( function( cmd ) {
47+
3948
cmd.updatable = false;
40-
});
49+
50+
} );
4151

4252
var secondMultiCmd = new CmdMultiCmds( secondMultiCmds );
4353
secondMultiCmd.updatable = false;
@@ -62,4 +72,4 @@ test( "Test CmdMultiCmds (Undo and Redo)", function() {
6272
ok( box.rotation.x == 0.4, "OK, x rotation has been modified accordingly after two multi executes (expected: 0.4, actual: " + box.rotation.x + ") " );
6373
ok( box.scale.z == 1.6, "OK, z scale has been modified accordingly after two multi executes (expected: 1.6, actual: " + box.scale.z + ")" );
6474

65-
});
75+
} );
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module("CmdRemoveScript");
1+
module( "CmdRemoveScript" );
22

33
test( "Test CmdRemoveScript (Undo and Redo)", function() {
44

@@ -15,41 +15,45 @@ test( "Test CmdRemoveScript (Undo and Redo)", function() {
1515

1616
// add objects to editor
1717
objects.map( function( item ) {
18+
1819
editor.execute( new CmdAddObject( item ) );
19-
});
20+
21+
} );
2022
ok( editor.scene.children.length == 2, "OK, the box and the sphere have been added" );
2123

2224
// add scripts to the objects
23-
for ( var i = 0; i < scripts.length; i++ ) {
25+
for ( var i = 0; i < scripts.length; i ++ ) {
2426

25-
var cmd = new CmdAddScript( objects[i], scripts[i] );
27+
var cmd = new CmdAddScript( objects[ i ], scripts[ i ] );
2628
cmd.updatable = false;
2729
editor.execute( cmd );
2830

2931
}
3032

31-
for ( var i = 0; i < scripts.length; i++ ) {
33+
for ( var i = 0; i < scripts.length; i ++ ) {
3234

33-
var cmd = new CmdRemoveScript( objects[i], scripts[i] );
35+
var cmd = new CmdRemoveScript( objects[ i ], scripts[ i ] );
3436
cmd.updatable = false;
3537
editor.execute( cmd );
3638

3739
}
3840
ok( getScriptCount( editor ) == 0, "OK, all scripts have been removed" );
3941

4042
scripts.map( function() {
43+
4144
editor.undo();
42-
});
45+
46+
} );
4347
ok( getScriptCount( editor ) == scripts.length, "OK, all scripts have been added again by undo(s)" );
4448

4549
var scriptsKeys = Object.keys( editor.scripts );
46-
for (var i = 0; i < scriptsKeys.length; i++ ) {
50+
for ( var i = 0; i < scriptsKeys.length; i ++ ) {
4751

48-
ok( editor.scripts[ scriptsKeys[i] ][0] == scripts[i], "OK, script #" + i + " is still assigned correctly" );
52+
ok( editor.scripts[ scriptsKeys[ i ] ][ 0 ] == scripts[ i ], "OK, script #" + i + " is still assigned correctly" );
4953

5054
}
5155

5256
editor.redo();
5357
ok( getScriptCount( editor ) == scripts.length - 1, "OK, one script has been removed again by redo" );
5458

55-
});
59+
} );

test/unit/editor/TestCmdSetColor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module( "CmdSetColor" );
22

3-
test("Test CmdSetColor (Undo and Redo)", function() {
3+
test( "Test CmdSetColor (Undo and Redo)", function() {
44

55
var editor = new Editor();
66
var pointLight = aPointlight( "The light Light" );
@@ -18,7 +18,7 @@ test("Test CmdSetColor (Undo and Redo)", function() {
1818
cmd.updatable = false;
1919
editor.execute( cmd );
2020

21-
});
21+
} );
2222

2323
ok( pointLight.color.getHex() == colors[ colors.length - 1 ],
2424
"OK, color has been set successfully (expected: '" + colors[ colors.length - 1 ] + "', actual: '" + pointLight.color.getHex() + "')" );
@@ -32,4 +32,4 @@ test("Test CmdSetColor (Undo and Redo)", function() {
3232
"OK, color has been set successfully after redo (expected: '" + colors[ colors.length - 1 ] + "', actual: '" + pointLight.color.getHex() + "')" );
3333

3434

35-
});
35+
} );

0 commit comments

Comments
 (0)