diff --git a/tests/jsunit/index.html b/tests/jsunit/index.html index 619e4143b..500f2cb37 100644 --- a/tests/jsunit/index.html +++ b/tests/jsunit/index.html @@ -25,9 +25,9 @@ + - diff --git a/tests/jsunit/procedures_test.js b/tests/jsunit/procedures_test.js index f993af892..9d1468af2 100644 --- a/tests/jsunit/procedures_test.js +++ b/tests/jsunit/procedures_test.js @@ -37,7 +37,6 @@ function proceduresTest_setUpWithMockBlocks() { 'message0': '%1', 'args0': [ { - // TODO: Why is this a variable? It shouldn't need to be. 'type': 'field_variable', 'name': 'NAME', 'variable': 'item' diff --git a/tests/jsunit/test_utilities.js b/tests/jsunit/test_utilities.js index aa5840d9e..39e63eeea 100644 --- a/tests/jsunit/test_utilities.js +++ b/tests/jsunit/test_utilities.js @@ -122,3 +122,21 @@ function createVariableAndBlock(workspace) { workspace.createVariable('name1', 'type1', 'id1'); createMockBlock('id1'); } + +function defineGetVarBlock() { + Blockly.defineBlocksWithJsonArray([{ + "type": "get_var_block", + "message0": "%1", + "args0": [ + { + "type": "field_variable", + "name": "VAR", + "variableTypes": ["", "type1", "type2"] + } + ] + }]); +} + +function undefineGetVarBlock() { + delete Blockly.Blocks['get_var_block']; +} diff --git a/tests/jsunit/workspace_test.js b/tests/jsunit/workspace_test.js index e991106a3..20421d711 100644 --- a/tests/jsunit/workspace_test.js +++ b/tests/jsunit/workspace_test.js @@ -26,23 +26,13 @@ var workspace; var mockControl_; function workspaceTest_setUp() { - Blockly.defineBlocksWithJsonArray([{ - "type": "get_var_block", - "message0": "%1", - "args0": [ - { - "type": "field_variable", - "name": "VAR", - "variableTypes": ["", "type1", "type2"] - } - ] - }]); + defineGetVarBlock(); workspace = new Blockly.Workspace(); mockControl_ = new goog.testing.MockControl(); } function workspaceTest_tearDown() { - delete Blockly.Blocks['get_var_block']; + undefineGetVarBlock(); mockControl_.$tearDown(); workspace.dispose(); } diff --git a/tests/jsunit/workspace_undo_redo_test.js b/tests/jsunit/workspace_undo_redo_test.js index f014c8ba2..aa960d9f0 100644 --- a/tests/jsunit/workspace_undo_redo_test.js +++ b/tests/jsunit/workspace_undo_redo_test.js @@ -43,24 +43,14 @@ function temporary_fireEvent(event) { } function undoRedoTest_setUp() { - Blockly.defineBlocksWithJsonArray([{ - "type": "get_var_block", - "message0": "%1", - "args0": [ - { - "type": "field_variable", - "name": "VAR", - "variableTypes": ["", "type1", "type2"] - } - ] - }]); + defineGetVarBlock(); workspace = new Blockly.Workspace(); mockControl_ = new goog.testing.MockControl(); Blockly.Events.fire = temporary_fireEvent; } function undoRedoTest_tearDown() { - delete Blockly.Blocks['get_var_block']; + undefineGetVarBlock(); mockControl_.$tearDown(); workspace.dispose(); Blockly.Events.fire = savedFireFunc;