Skip to content

Commit 2e129a8

Browse files
author
Mario Schuettel
committed
added test for CmdSetGeometryValue
1 parent 4647e72 commit 2e129a8

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module( "CmdSetGeometryValue" );
2+
3+
test( "Test CmdSetGeometryValue (Undo and Redo)", function() {
4+
5+
var editor = new Editor();
6+
var box = aBox( 'The Box' );
7+
8+
var cmd = new CmdAddObject( box );
9+
cmd.updatable = false;
10+
editor.execute( cmd );
11+
12+
var testData = [
13+
{ uuid: THREE.Math.generateUUID(), name: 'Bruno' },
14+
{ uuid: THREE.Math.generateUUID(), name: 'Jack' }
15+
];
16+
17+
for( var i = 0; i < testData.length; i++ ) {
18+
19+
var keys = Object.keys( testData[ i ] );
20+
21+
keys.map( function( key ) {
22+
23+
cmd = new CmdSetGeometryValue( box, key, testData[ i ][ key ] );
24+
cmd.updatable = false;
25+
editor.execute( cmd );
26+
27+
});
28+
29+
}
30+
31+
ok( box.geometry.name == testData[ 1 ].name, "OK, box.geometry.name is correct after executes" );
32+
ok( box.geometry.uuid == testData[ 1 ].uuid, "OK, box.geometry.uuid is correct after executes" );
33+
34+
editor.undo();
35+
editor.undo();
36+
37+
ok( box.geometry.name == testData[ 0 ].name, "OK, box.geometry.name is correct after undos" );
38+
ok( box.geometry.uuid == testData[ 0 ].uuid, "OK, box.geometry.uuid is correct after undos" );
39+
40+
editor.redo();
41+
editor.redo();
42+
43+
ok( box.geometry.name == testData[ 1 ].name, "OK, box.geometry.name is correct after executes" );
44+
ok( box.geometry.uuid == testData[ 1 ].uuid, "OK, box.geometry.uuid is correct after executes" );
45+
46+
});

test/unit/unittests_editor.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<script src="../../editor/js/CmdRemoveScript.js"></script>
8080
<script src="../../editor/js/CmdSetColor.js"></script>
8181
<script src="../../editor/js/CmdSetGeometry.js"></script>
82+
<script src="../../editor/js/CmdSetGeometryValue.js"></script>
8283
<script src="../../editor/js/CmdSetPosition.js"></script>
8384
<script src="../../editor/js/CmdSetRotation.js"></script>
8485
<script src="../../editor/js/CmdSetScale.js"></script>
@@ -101,6 +102,7 @@
101102
<script src="editor/TestCmdRemoveScript.js"></script>
102103
<script src="editor/TestCmdSetColor.js"></script>
103104
<script src="editor/TestCmdSetGeometry.js"></script>
105+
<script src="editor/TestCmdSetGeometryValue.js"></script>
104106
<script src="editor/TestCmdSetPosition.js"></script>
105107
<script src="editor/TestCmdSetRotation.js"></script>
106108
<script src="editor/TestCmdSetScale.js"></script>

0 commit comments

Comments
 (0)