From 8a78f680a855d9cf7b1afad9c34e3d9024165527 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 1 Mar 2022 18:22:32 +0000 Subject: [PATCH] fix: split block defs into new helper file --- tests/deps.mocha.js | 41 ++-- tests/mocha/block_change_event_test.js | 3 +- tests/mocha/block_test.js | 3 +- tests/mocha/connection_test.js | 3 +- tests/mocha/field_angle_test.js | 3 +- tests/mocha/field_checkbox_test.js | 3 +- tests/mocha/field_colour_test.js | 3 +- tests/mocha/field_dropdown_test.js | 3 +- tests/mocha/field_label_serializable_test.js | 3 +- tests/mocha/field_label_test.js | 3 +- tests/mocha/field_multilineinput_test.js | 3 +- tests/mocha/field_number_test.js | 3 +- tests/mocha/field_textinput_test.js | 3 +- tests/mocha/field_variable_test.js | 3 +- tests/mocha/gesture_test.js | 4 +- tests/mocha/jso_serialization_test.js | 3 +- tests/mocha/keydown_test.js | 3 +- tests/mocha/mutator_test.js | 3 +- tests/mocha/test_helpers/block_definitions.js | 185 ++++++++++++++++++ tests/mocha/test_helpers/test_helpers.js | 177 ----------------- tests/mocha/toolbox_test.js | 3 +- tests/mocha/trashcan_test.js | 3 +- tests/mocha/workspace_svg_test.js | 4 +- 23 files changed, 246 insertions(+), 219 deletions(-) create mode 100644 tests/mocha/test_helpers/block_definitions.js diff --git a/tests/deps.mocha.js b/tests/deps.mocha.js index a2782f746..d8efab76a 100644 --- a/tests/deps.mocha.js +++ b/tests/deps.mocha.js @@ -1,49 +1,50 @@ goog.addDependency('../../tests/mocha/.mocharc.js', [], []); goog.addDependency('../../tests/mocha/astnode_test.js', ['Blockly.test.astNode'], ['Blockly.ASTNode', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/block_change_event_test.js', ['Blockly.test.blockChangeEvent'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/block_change_event_test.js', ['Blockly.test.blockChangeEvent'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/block_create_event_test.js', ['Blockly.test.blockCreateEvent'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/block_json_test.js', ['Blockly.test.blockJson'], ['Blockly.Input'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/block_test.js', ['Blockly.test.blocks'], ['Blockly.ConnectionType', 'Blockly.Events.utils', 'Blockly.blocks', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/block_test.js', ['Blockly.test.blocks'], ['Blockly.ConnectionType', 'Blockly.Events.utils', 'Blockly.blocks', 'Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/comment_test.js', ['Blockly.test.comments'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/connection_checker_test.js', ['Blockly.test.connectionChecker'], ['Blockly.ConnectionType', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/connection_db_test.js', ['Blockly.test.connectionDb'], ['Blockly.ConnectionType', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/connection_test.js', ['Blockly.test.connection'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/connection_test.js', ['Blockly.test.connection'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/contextmenu_items_test.js', ['Blockly.test.contextMenuItem'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/cursor_test.js', ['Blockly.test.cursor'], ['Blockly.ASTNode', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/dropdowndiv_test.js', ['Blockly.test.dropdown'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/event_test.js', ['Blockly.test.event'], ['Blockly.ASTNode', 'Blockly.Events.utils', 'Blockly.WorkspaceComment', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/extensions_test.js', ['Blockly.test.extensions'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_angle_test.js', ['Blockly.test.fieldAngle'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_checkbox_test.js', ['Blockly.test.fieldCheckbox'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_colour_test.js', ['Blockly.test.fieldColour'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_dropdown_test.js', ['Blockly.test.fieldDropdown'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_angle_test.js', ['Blockly.test.fieldAngle'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_checkbox_test.js', ['Blockly.test.fieldCheckbox'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_colour_test.js', ['Blockly.test.fieldColour'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_dropdown_test.js', ['Blockly.test.fieldDropdown'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/field_image_test.js', ['Blockly.test.fieldImage'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_label_serializable_test.js', ['Blockly.test.fieldLabelSerialization'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_label_test.js', ['Blockly.test.fieldLabel'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_multilineinput_test.js', ['Blockly.test.fieldMultiline'], ['Blockly.test.helpers', 'Blockly.test.helpers.codeGeneration', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_number_test.js', ['Blockly.test.fieldNumber'], ['Blockly.test.helpers', 'Blockly.test.helpers.common', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_label_serializable_test.js', ['Blockly.test.fieldLabelSerialization'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_label_test.js', ['Blockly.test.fieldLabel'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_multilineinput_test.js', ['Blockly.test.fieldMultiline'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.codeGeneration', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_number_test.js', ['Blockly.test.fieldNumber'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.common', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/field_registry_test.js', ['Blockly.test.fieldRegistry'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/field_test.js', ['Blockly.test.fieldTest'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_textinput_test.js', ['Blockly.test.fieldTextInput'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/field_variable_test.js', ['Blockly.test.fieldVariable'], ['Blockly.test.helpers', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_textinput_test.js', ['Blockly.test.fieldTextInput'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/field_variable_test.js', ['Blockly.test.fieldVariable'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/flyout_test.js', ['Blockly.test.flyout'], ['Blockly.test.helpers', 'Blockly.test.helpers.toolbox_definitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/generator_test.js', ['Blockly.test.generator'], ['Blockly.Dart', 'Blockly.JavaScript', 'Blockly.Lua', 'Blockly.PHP', 'Blockly.Python', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/gesture_test.js', ['Blockly.test.gesture'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/gesture_test.js', ['Blockly.test.gesture'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/input_test.js', ['Blockly.test.input'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/insertion_marker_test.js', ['Blockly.test.insertionMarker'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/jso_deserialization_test.js', ['Blockly.test.jsoDeserialization'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/jso_serialization_test.js', ['Blockly.test.jsoSerialization'], ['Blockly.test.helpers'], {'lang': 'es8', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/jso_serialization_test.js', ['Blockly.test.jsoSerialization'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions'], {'lang': 'es8', 'module': 'goog'}); goog.addDependency('../../tests/mocha/json_test.js', ['Blockly.test.json'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/keydown_test.js', ['Blockly.test.keydown'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/keydown_test.js', ['Blockly.test.keydown'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/logic_ternary_test.js', ['Blockly.test.logicTernary'], ['Blockly.Events.utils', 'Blockly.test.helpers', 'Blockly.test.helpers.serialization'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/metrics_test.js', ['Blockly.test.metrics'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/mutator_test.js', ['Blockly.test.mutator'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/mutator_test.js', ['Blockly.test.mutator'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/names_test.js', ['Blockly.test.names'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/procedures_test.js', ['Blockly.test.procedures'], ['Blockly', 'Blockly.Msg', 'Blockly.test.helpers', 'Blockly.test.helpers.procedures', 'Blockly.test.helpers.serialization'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/registry_test.js', ['Blockly.test.registry'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/run_mocha_tests_in_browser.js', [], [], {'lang': 'es8'}); goog.addDependency('../../tests/mocha/serializer_test.js', ['Blockly.test.serialization'], ['Blockly.test.helpers', 'Blockly.test.helpers.common'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/shortcut_registry_test.js', ['Blockly.test.shortcutRegistry'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/test_helpers/block_definitions.js', ['Blockly.test.helpers.blockDefinitions'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/test_helpers/code_generation.js', ['Blockly.test.helpers.codeGeneration'], ['Blockly.test.helpers.common'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/test_helpers/common.js', ['Blockly.test.helpers.common'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/test_helpers/fields.js', ['Blockly.test.helpers.fields'], ['Blockly.test.helpers.common'], {'lang': 'es6', 'module': 'goog'}); @@ -53,16 +54,16 @@ goog.addDependency('../../tests/mocha/test_helpers/test_helpers.js', ['Blockly.t goog.addDependency('../../tests/mocha/test_helpers/toolbox_definitions.js', ['Blockly.test.helpers.toolbox_definitions'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/test_helpers/workspace.js', ['Blockly.test.helpers.workspace'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/theme_test.js', ['Blockly.test.theme'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/toolbox_test.js', ['Blockly.test.toolbox'], ['Blockly.test.helpers', 'Blockly.test.helpers.toolbox_definitions'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/toolbox_test.js', ['Blockly.test.toolbox'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.toolbox_definitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/tooltip_test.js', ['Blockly.test.tooltip'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/trashcan_test.js', ['Blockly.test.trashcan'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/trashcan_test.js', ['Blockly.test.trashcan'], ['Blockly.Events.utils', 'Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/utils_test.js', ['Blockly.test.utils'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/variable_map_test.js', ['Blockly.test.variableMap'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/variable_model_test.js', ['Blockly.test.variableModel'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/variables_test.js', ['Blockly.test.variables'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/widget_div_test.js', ['Blockly.test.widgetDiv'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/workspace_comment_test.js', ['Blockly.test.workspaceComment'], ['Blockly.WorkspaceComment', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../tests/mocha/workspace_svg_test.js', ['Blockly.test.workspaceSvg'], ['Blockly.Events.utils', 'Blockly.test.helpers', 'Blockly.test.helpers.workspace'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../tests/mocha/workspace_svg_test.js', ['Blockly.test.workspaceSvg'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.workspace'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/workspace_test.js', ['Blockly.test.workspace'], ['Blockly.test.helpers', 'Blockly.test.helpers.workspace'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/xml_test.js', ['Blockly.test.xml'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../tests/mocha/zoom_controls_test.js', ['Blockly.test.zoomControls'], ['Blockly.Events.utils', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'}); diff --git a/tests/mocha/block_change_event_test.js b/tests/mocha/block_change_event_test.js index e4e3f49cf..ce290cee0 100644 --- a/tests/mocha/block_change_event_test.js +++ b/tests/mocha/block_change_event_test.js @@ -6,7 +6,8 @@ goog.module('Blockly.test.blockChangeEvent'); -const {defineMutatorBlocks, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {defineMutatorBlocks} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Block Change Event', function() { diff --git a/tests/mocha/block_test.js b/tests/mocha/block_test.js index 36cc583d9..6d88d4ad1 100644 --- a/tests/mocha/block_test.js +++ b/tests/mocha/block_test.js @@ -9,7 +9,8 @@ goog.module('Blockly.test.blocks'); const eventUtils = goog.require('Blockly.Events.utils'); const {Blocks} = goog.require('Blockly.blocks'); const {ConnectionType} = goog.require('Blockly.ConnectionType'); -const {createDeprecationWarningStub, createRenderedBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createDeprecationWarningStub, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createRenderedBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Blocks', function() { diff --git a/tests/mocha/connection_test.js b/tests/mocha/connection_test.js index 24e763683..9275eadfd 100644 --- a/tests/mocha/connection_test.js +++ b/tests/mocha/connection_test.js @@ -6,7 +6,8 @@ goog.module('Blockly.test.connection'); -const {assertSingleDeprecationWarningCall, createDeprecationWarningStub, createGenUidStubWithReturns, defineRowBlock, defineStatementBlock, defineStackBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {assertSingleDeprecationWarningCall, createDeprecationWarningStub, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {defineRowBlock, defineStatementBlock, defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Connection', function() { diff --git a/tests/mocha/field_angle_test.js b/tests/mocha/field_angle_test.js index b93926a0d..a1928b8ac 100644 --- a/tests/mocha/field_angle_test.js +++ b/tests/mocha/field_angle_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldAngle'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); suite('Angle Fields', function() { diff --git a/tests/mocha/field_checkbox_test.js b/tests/mocha/field_checkbox_test.js index 0640e238e..163b9cbb0 100644 --- a/tests/mocha/field_checkbox_test.js +++ b/tests/mocha/field_checkbox_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldCheckbox'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Checkbox Fields', function() { diff --git a/tests/mocha/field_colour_test.js b/tests/mocha/field_colour_test.js index 14725913d..5bf1786d6 100644 --- a/tests/mocha/field_colour_test.js +++ b/tests/mocha/field_colour_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldColour'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); suite('Colour Fields', function() { diff --git a/tests/mocha/field_dropdown_test.js b/tests/mocha/field_dropdown_test.js index 0b9338a9e..8c3be333b 100644 --- a/tests/mocha/field_dropdown_test.js +++ b/tests/mocha/field_dropdown_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldDropdown'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); suite('Dropdown Fields', function() { diff --git a/tests/mocha/field_label_serializable_test.js b/tests/mocha/field_label_serializable_test.js index d227962d9..8e345572d 100644 --- a/tests/mocha/field_label_serializable_test.js +++ b/tests/mocha/field_label_serializable_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldLabelSerialization'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Label Serializable Fields', function() { diff --git a/tests/mocha/field_label_test.js b/tests/mocha/field_label_test.js index 754554c9f..f62860f23 100644 --- a/tests/mocha/field_label_test.js +++ b/tests/mocha/field_label_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldLabel'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {createTestBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Label Fields', function() { diff --git a/tests/mocha/field_multilineinput_test.js b/tests/mocha/field_multilineinput_test.js index 4a2cc807e..0840f500f 100644 --- a/tests/mocha/field_multilineinput_test.js +++ b/tests/mocha/field_multilineinput_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldMultiline'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); const {runCodeGenerationTestSuites} = goog.require('Blockly.test.helpers.codeGeneration'); diff --git a/tests/mocha/field_number_test.js b/tests/mocha/field_number_test.js index e6d3f7eb6..b2fd90e86 100644 --- a/tests/mocha/field_number_test.js +++ b/tests/mocha/field_number_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldNumber'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); const {runTestCases} = goog.require('Blockly.test.helpers.common'); diff --git a/tests/mocha/field_textinput_test.js b/tests/mocha/field_textinput_test.js index 4dc10aeeb..d6f53f691 100644 --- a/tests/mocha/field_textinput_test.js +++ b/tests/mocha/field_textinput_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldTextInput'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); suite('Text Input Fields', function() { diff --git a/tests/mocha/field_variable_test.js b/tests/mocha/field_variable_test.js index ed8dccbbc..b0a025baf 100644 --- a/tests/mocha/field_variable_test.js +++ b/tests/mocha/field_variable_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.fieldVariable'); const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createGenUidStubWithReturns, createTestBlock, defineRowBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Variable Fields', function() { diff --git a/tests/mocha/gesture_test.js b/tests/mocha/gesture_test.js index 16a6cadda..56cf00c8b 100644 --- a/tests/mocha/gesture_test.js +++ b/tests/mocha/gesture_test.js @@ -6,8 +6,8 @@ goog.module('Blockly.test.gesture'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {assertEventFired, assertEventNotFired, defineBasicBlockWithField, dispatchPointerEvent, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {assertEventFired, assertEventNotFired, dispatchPointerEvent, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {defineBasicBlockWithField} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Gesture', function() { diff --git a/tests/mocha/jso_serialization_test.js b/tests/mocha/jso_serialization_test.js index 02d97e34e..e3278abfd 100644 --- a/tests/mocha/jso_serialization_test.js +++ b/tests/mocha/jso_serialization_test.js @@ -6,7 +6,8 @@ goog.module('Blockly.test.jsoSerialization'); -const {defineStackBlock, defineRowBlock, defineStatementBlock, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {defineRowBlock, defineStackBlock, defineStatementBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('JSO Serialization', function() { diff --git a/tests/mocha/keydown_test.js b/tests/mocha/keydown_test.js index 9236e3784..b37a1b43d 100644 --- a/tests/mocha/keydown_test.js +++ b/tests/mocha/keydown_test.js @@ -6,7 +6,8 @@ goog.module('Blockly.test.keydown'); -const {createKeyDownEvent, defineStackBlock, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {createKeyDownEvent, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Key Down', function() { diff --git a/tests/mocha/mutator_test.js b/tests/mocha/mutator_test.js index af5f22cdf..ef3e42a1f 100644 --- a/tests/mocha/mutator_test.js +++ b/tests/mocha/mutator_test.js @@ -7,7 +7,8 @@ goog.module('Blockly.test.mutator'); -const {createRenderedBlock, defineMutatorBlocks, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {createRenderedBlock, defineMutatorBlocks} = goog.require('Blockly.test.helpers.blockDefinitions'); suite('Mutator', function() { diff --git a/tests/mocha/test_helpers/block_definitions.js b/tests/mocha/test_helpers/block_definitions.js new file mode 100644 index 000000000..e8dd44030 --- /dev/null +++ b/tests/mocha/test_helpers/block_definitions.js @@ -0,0 +1,185 @@ +/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +goog.module('Blockly.test.helpers.blockDefinitions'); + + +function defineStackBlock(name = 'stack_block') { + Blockly.defineBlocksWithJsonArray([{ + "type": name, + "message0": "", + "previousStatement": null, + "nextStatement": null, + }]); +} +exports.defineStackBlock = defineStackBlock; + +function defineRowBlock(name = 'row_block') { + Blockly.defineBlocksWithJsonArray([{ + "type": name, + "message0": "%1", + "args0": [ + { + "type": "input_value", + "name": "INPUT", + }, + ], + "output": null, + }]); +} +exports.defineRowBlock = defineRowBlock; + +function defineStatementBlock(name = 'statement_block') { + Blockly.defineBlocksWithJsonArray([{ + "type": name, + "message0": "%1", + "args0": [ + { + "type": "input_statement", + "name": "NAME", + }, + ], + "previousStatement": null, + "nextStatement": null, + "colour": 230, + "tooltip": "", + "helpUrl": "", + }]); +} +exports.defineStatementBlock = defineStatementBlock; + +function defineBasicBlockWithField(name = 'test_field_block') { + Blockly.defineBlocksWithJsonArray([{ + "type": name, + "message0": "%1", + "args0": [ + { + "type": "field_input", + "name": "NAME", + }, + ], + "output": null, + }]); +} +exports.defineBasicBlockWithField = defineBasicBlockWithField; + +function defineMutatorBlocks() { + Blockly.defineBlocksWithJsonArray([ + { + 'type': 'xml_block', + 'mutator': 'xml_mutator', + }, + { + 'type': 'jso_block', + 'mutator': 'jso_mutator', + }, + { + 'type': 'checkbox_block', + 'message0': '%1', + 'args0': [ + { + 'type': 'field_checkbox', + 'name': 'CHECK', + }, + ], + }, + ]); + + const xmlMutator = { + hasInput: false, + + mutationToDom: function() { + const mutation = Blockly.utils.xml.createElement('mutation'); + mutation.setAttribute('hasInput', this.hasInput); + return mutation; + }, + + domToMutation: function(mutation) { + this.hasInput = mutation.getAttribute('hasInput') == 'true'; + this.updateShape(); + }, + + decompose: function(workspace) { + const topBlock = workspace.newBlock('checkbox_block', 'check_block'); + topBlock.initSvg(); + topBlock.render(); + return topBlock; + }, + + compose: function(topBlock) { + this.hasInput = topBlock.getFieldValue('CHECK') == 'TRUE'; + this.updateShape(); + }, + + updateShape: function() { + if (this.hasInput && !this.getInput('INPUT')) { + this.appendValueInput('INPUT'); + } else if (!this.hasInput && this.getInput('INPUT')) { + this.removeInput('INPUT'); + } + }, + }; + Blockly.Extensions.registerMutator('xml_mutator', xmlMutator); + + const jsoMutator = { + hasInput: false, + + saveExtraState: function() { + return {hasInput: this.hasInput}; + }, + + loadExtraState: function(state) { + this.hasInput = state.hasInput || false; + this.updateShape(); + }, + + decompose: function(workspace) { + const topBlock = workspace.newBlock('checkbox_block', 'check_block'); + topBlock.initSvg(); + topBlock.render(); + return topBlock; + }, + + compose: function(topBlock) { + this.hasInput = topBlock.getFieldValue('CHECK') == 'TRUE'; + this.updateShape(); + }, + + updateShape: function() { + if (this.hasInput && !this.getInput('INPUT')) { + this.appendValueInput('INPUT'); + } else if (!this.hasInput && this.getInput('INPUT')) { + this.removeInput('INPUT'); + } + }, + }; + Blockly.Extensions.registerMutator('jso_mutator', jsoMutator); +} +exports.defineMutatorBlocks = defineMutatorBlocks; + +function createTestBlock() { + return { + 'id': 'test', + 'rendered': false, + 'workspace': { + 'rendered': false, + }, + 'isShadow': function() { + return false; + }, + 'renameVarById': Blockly.Block.prototype.renameVarById, + 'updateVarName': Blockly.Block.prototype.updateVarName, + }; +} +exports.createTestBlock = createTestBlock; + +function createRenderedBlock(workspaceSvg, type) { + const block = workspaceSvg.newBlock(type); + block.initSvg(); + block.render(); + return block; +} +exports.createRenderedBlock = createRenderedBlock; \ No newline at end of file diff --git a/tests/mocha/test_helpers/test_helpers.js b/tests/mocha/test_helpers/test_helpers.js index 82d4fcadf..f147b0bc8 100644 --- a/tests/mocha/test_helpers/test_helpers.js +++ b/tests/mocha/test_helpers/test_helpers.js @@ -482,183 +482,6 @@ function assertNthCallEventArgEquals(spy, n, instanceType, expectedProperties, } exports.assertNthCallEventArgEquals = assertNthCallEventArgEquals; -function defineStackBlock(name = 'stack_block') { - Blockly.defineBlocksWithJsonArray([{ - "type": name, - "message0": "", - "previousStatement": null, - "nextStatement": null, - }]); -} -exports.defineStackBlock = defineStackBlock; - -function defineRowBlock(name = 'row_block') { - Blockly.defineBlocksWithJsonArray([{ - "type": name, - "message0": "%1", - "args0": [ - { - "type": "input_value", - "name": "INPUT", - }, - ], - "output": null, - }]); -} -exports.defineRowBlock = defineRowBlock; - -function defineStatementBlock(name = 'statement_block') { - Blockly.defineBlocksWithJsonArray([{ - "type": name, - "message0": "%1", - "args0": [ - { - "type": "input_statement", - "name": "NAME", - }, - ], - "previousStatement": null, - "nextStatement": null, - "colour": 230, - "tooltip": "", - "helpUrl": "", - }]); -} -exports.defineStatementBlock = defineStatementBlock; - -function defineBasicBlockWithField(name = 'test_field_block') { - Blockly.defineBlocksWithJsonArray([{ - "type": name, - "message0": "%1", - "args0": [ - { - "type": "field_input", - "name": "NAME", - }, - ], - "output": null, - }]); -} -exports.defineBasicBlockWithField = defineBasicBlockWithField; - -function defineMutatorBlocks() { - Blockly.defineBlocksWithJsonArray([ - { - 'type': 'xml_block', - 'mutator': 'xml_mutator', - }, - { - 'type': 'jso_block', - 'mutator': 'jso_mutator', - }, - { - 'type': 'checkbox_block', - 'message0': '%1', - 'args0': [ - { - 'type': 'field_checkbox', - 'name': 'CHECK', - }, - ], - }, - ]); - - const xmlMutator = { - hasInput: false, - - mutationToDom: function() { - const mutation = Blockly.utils.xml.createElement('mutation'); - mutation.setAttribute('hasInput', this.hasInput); - return mutation; - }, - - domToMutation: function(mutation) { - this.hasInput = mutation.getAttribute('hasInput') == 'true'; - this.updateShape(); - }, - - decompose: function(workspace) { - const topBlock = workspace.newBlock('checkbox_block', 'check_block'); - topBlock.initSvg(); - topBlock.render(); - return topBlock; - }, - - compose: function(topBlock) { - this.hasInput = topBlock.getFieldValue('CHECK') == 'TRUE'; - this.updateShape(); - }, - - updateShape: function() { - if (this.hasInput && !this.getInput('INPUT')) { - this.appendValueInput('INPUT'); - } else if (!this.hasInput && this.getInput('INPUT')) { - this.removeInput('INPUT'); - } - }, - }; - Blockly.Extensions.registerMutator('xml_mutator', xmlMutator); - - const jsoMutator = { - hasInput: false, - - saveExtraState: function() { - return {hasInput: this.hasInput}; - }, - - loadExtraState: function(state) { - this.hasInput = state.hasInput || false; - this.updateShape(); - }, - - decompose: function(workspace) { - const topBlock = workspace.newBlock('checkbox_block', 'check_block'); - topBlock.initSvg(); - topBlock.render(); - return topBlock; - }, - - compose: function(topBlock) { - this.hasInput = topBlock.getFieldValue('CHECK') == 'TRUE'; - this.updateShape(); - }, - - updateShape: function() { - if (this.hasInput && !this.getInput('INPUT')) { - this.appendValueInput('INPUT'); - } else if (!this.hasInput && this.getInput('INPUT')) { - this.removeInput('INPUT'); - } - }, - }; - Blockly.Extensions.registerMutator('jso_mutator', jsoMutator); -} -exports.defineMutatorBlocks = defineMutatorBlocks; - -function createTestBlock() { - return { - 'id': 'test', - 'rendered': false, - 'workspace': { - 'rendered': false, - }, - 'isShadow': function() { - return false; - }, - 'renameVarById': Blockly.Block.prototype.renameVarById, - 'updateVarName': Blockly.Block.prototype.updateVarName, - }; -} -exports.createTestBlock = createTestBlock; - -function createRenderedBlock(workspaceSvg, type) { - const block = workspaceSvg.newBlock(type); - block.initSvg(); - block.render(); - return block; -} -exports.createRenderedBlock = createRenderedBlock; - /** * Triggers pointer event on target. * @param {!EventTarget} target The object receiving the event. diff --git a/tests/mocha/toolbox_test.js b/tests/mocha/toolbox_test.js index 40c601427..381e799d2 100644 --- a/tests/mocha/toolbox_test.js +++ b/tests/mocha/toolbox_test.js @@ -6,7 +6,8 @@ goog.module('Blockly.test.toolbox'); -const {defineStackBlock, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); +const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers'); const {getBasicToolbox, getCategoryJSON, getChildItem, getCollapsibleItem, getDeeplyNestedJSON, getInjectedToolbox, getNonCollapsibleItem, getSeparator, getSimpleJson, getXmlArray} = goog.require('Blockly.test.helpers.toolbox_definitions'); diff --git a/tests/mocha/trashcan_test.js b/tests/mocha/trashcan_test.js index d82f60699..6ea1dbe38 100644 --- a/tests/mocha/trashcan_test.js +++ b/tests/mocha/trashcan_test.js @@ -6,8 +6,9 @@ goog.module('Blockly.test.trashcan'); +const {assertEventFired, assertEventNotFired, sharedTestSetup, sharedTestTeardown, simulateClick} = goog.require('Blockly.test.helpers'); +const {defineBasicBlockWithField, defineMutatorBlocks, defineRowBlock, defineStackBlock, defineStatementBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); const eventUtils = goog.require('Blockly.Events.utils'); -const {assertEventFired, assertEventNotFired, defineBasicBlockWithField, defineRowBlock, defineStatementBlock, defineStackBlock, defineMutatorBlocks, sharedTestSetup, sharedTestTeardown, simulateClick} = goog.require('Blockly.test.helpers'); suite("Trashcan", function() { diff --git a/tests/mocha/workspace_svg_test.js b/tests/mocha/workspace_svg_test.js index 2b3de18da..012b10541 100644 --- a/tests/mocha/workspace_svg_test.js +++ b/tests/mocha/workspace_svg_test.js @@ -6,8 +6,8 @@ goog.module('Blockly.test.workspaceSvg'); -const {assertEventFired, assertEventNotFired, assertVariableValues, createFireChangeListenerSpy, defineStackBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); -const eventUtils = goog.require('Blockly.Events.utils'); +const {assertEventFired, assertEventNotFired, assertVariableValues, createFireChangeListenerSpy, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); const {testAWorkspace} = goog.require('Blockly.test.helpers.workspace');