From 96758fedd426abec216a8ef00a9be4999e48ecb5 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 10 Aug 2022 21:54:02 +0000 Subject: [PATCH] chore: convert mocha tests and test helpers to esmodules (#6333) * chore: change goog.module to goog.declareModuleId * chore: change test helper exports to esmod exports * chore: change test helpers to use esmodule imports * chore: convert imports of test helpers to esmodule imports * chore: convert other imports in tests to esm imports * fix: make imports use built files * chore: add blockly imports to a bunch of tests * fix: reference Blockly.Blocks instead of Blocks' * fix: properly import generators * chore: fix lint * chore: cleanup from rebase * chore: cleanup from rebase * chore: fix blocks tests --- tests/mocha/.eslintrc.json | 8 +++-- tests/mocha/astnode_test.js | 6 ++-- tests/mocha/block_change_event_test.js | 6 ++-- tests/mocha/block_create_event_test.js | 8 ++--- tests/mocha/block_json_test.js | 4 +-- tests/mocha/block_test.js | 15 ++++---- tests/mocha/blocks/lists_test.js | 10 +++--- tests/mocha/blocks/logic_ternary_test.js | 8 ++--- tests/mocha/blocks/procedures_test.js | 11 +++--- tests/mocha/blocks/variables_test.js | 4 +-- tests/mocha/comment_deserialization_test.js | 6 ++-- tests/mocha/comment_test.js | 8 ++--- tests/mocha/connection_checker_test.js | 6 ++-- tests/mocha/connection_db_test.js | 6 ++-- tests/mocha/connection_test.js | 6 ++-- tests/mocha/contextmenu_items_test.js | 4 +-- tests/mocha/cursor_test.js | 6 ++-- tests/mocha/dropdowndiv_test.js | 4 +-- tests/mocha/event_test.js | 15 ++++---- tests/mocha/extensions_test.js | 4 +-- tests/mocha/field_angle_test.js | 9 ++--- tests/mocha/field_checkbox_test.js | 9 ++--- tests/mocha/field_colour_test.js | 9 ++--- tests/mocha/field_dropdown_test.js | 9 ++--- tests/mocha/field_image_test.js | 7 ++-- tests/mocha/field_label_serializable_test.js | 9 ++--- tests/mocha/field_label_test.js | 9 ++--- tests/mocha/field_multilineinput_test.js | 16 ++++++--- tests/mocha/field_number_test.js | 11 +++--- tests/mocha/field_registry_test.js | 7 ++-- tests/mocha/field_test.js | 7 ++-- tests/mocha/field_textinput_test.js | 9 ++--- tests/mocha/field_variable_test.js | 9 ++--- tests/mocha/flyout_test.js | 7 ++-- tests/mocha/generator_test.js | 7 ++-- tests/mocha/gesture_test.js | 12 +++---- tests/mocha/input_test.js | 4 +-- tests/mocha/insertion_marker_test.js | 4 +-- tests/mocha/jso_deserialization_test.js | 8 ++--- tests/mocha/jso_serialization_test.js | 7 ++-- tests/mocha/json_test.js | 6 ++-- tests/mocha/keydown_test.js | 9 ++--- tests/mocha/metrics_test.js | 4 +-- tests/mocha/mutator_test.js | 6 ++-- tests/mocha/names_test.js | 4 +-- tests/mocha/registry_test.js | 6 ++-- tests/mocha/serializer_test.js | 7 ++-- tests/mocha/shortcut_registry_test.js | 6 ++-- tests/mocha/test_helpers/block_definitions.js | 23 +++++------- tests/mocha/test_helpers/code_generation.js | 13 +++---- tests/mocha/test_helpers/common.js | 14 +++----- tests/mocha/test_helpers/events.js | 17 ++++----- tests/mocha/test_helpers/fields.js | 22 +++++------- tests/mocha/test_helpers/procedures.js | 16 ++++----- tests/mocha/test_helpers/serialization.js | 10 +++--- tests/mocha/test_helpers/setup_teardown.js | 26 +++++--------- .../mocha/test_helpers/toolbox_definitions.js | 35 +++++++------------ tests/mocha/test_helpers/user_input.js | 13 +++---- tests/mocha/test_helpers/variables.js | 5 ++- tests/mocha/test_helpers/warnings.js | 20 ++++------- tests/mocha/test_helpers/workspace.js | 13 ++++--- tests/mocha/theme_test.js | 8 ++--- tests/mocha/toolbox_test.js | 8 ++--- tests/mocha/tooltip_test.js | 4 +-- tests/mocha/trashcan_test.js | 12 +++---- tests/mocha/utils_test.js | 4 +-- tests/mocha/variable_map_test.js | 6 ++-- tests/mocha/variable_model_test.js | 4 +-- tests/mocha/widget_div_test.js | 4 +-- tests/mocha/workspace_comment_test.js | 6 ++-- tests/mocha/workspace_svg_test.js | 14 ++++---- tests/mocha/workspace_test.js | 8 ++--- tests/mocha/xml_test.js | 6 ++-- tests/mocha/zoom_controls_test.js | 10 +++--- 74 files changed, 324 insertions(+), 359 deletions(-) diff --git a/tests/mocha/.eslintrc.json b/tests/mocha/.eslintrc.json index 8ebf31ae6..99dda9b38 100644 --- a/tests/mocha/.eslintrc.json +++ b/tests/mocha/.eslintrc.json @@ -11,7 +11,11 @@ "no-unused-vars": ["off"], // Allow uncommented helper functions in tests. "require-jsdoc": ["off"], - "prefer-rest-params": ["off"] + "prefer-rest-params": ["off"], + "no-invalid-this": ["off"] }, - "extends": "../../.eslintrc.json" + "extends": "../../.eslintrc.json", + "parserOptions": { + "sourceType": "module" + } } diff --git a/tests/mocha/astnode_test.js b/tests/mocha/astnode_test.js index f974f3ea8..52b173465 100644 --- a/tests/mocha/astnode_test.js +++ b/tests/mocha/astnode_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.astNode'); +goog.declareModuleId('Blockly.test.astNode'); -const {ASTNode} = goog.require('Blockly.ASTNode'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {ASTNode} from '../../build/src/core/keyboard_nav/ast_node.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('ASTNode', function() { diff --git a/tests/mocha/block_change_event_test.js b/tests/mocha/block_change_event_test.js index 6cfbca578..ecd62f4b4 100644 --- a/tests/mocha/block_change_event_test.js +++ b/tests/mocha/block_change_event_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.blockChangeEvent'); +goog.declareModuleId('Blockly.test.blockChangeEvent'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {defineMutatorBlocks} = goog.require('Blockly.test.helpers.blockDefinitions'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {defineMutatorBlocks} from './test_helpers/block_definitions.js'; suite('Block Change Event', function() { diff --git a/tests/mocha/block_create_event_test.js b/tests/mocha/block_create_event_test.js index 475991908..ddbb84d53 100644 --- a/tests/mocha/block_create_event_test.js +++ b/tests/mocha/block_create_event_test.js @@ -4,11 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.blockCreateEvent'); +goog.declareModuleId('Blockly.test.blockCreateEvent'); -const {assertEventFired} = goog.require('Blockly.test.helpers.events'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {assertEventFired} from './test_helpers/events.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Block Create Event', function() { diff --git a/tests/mocha/block_json_test.js b/tests/mocha/block_json_test.js index 0cad1ccd3..b2b15f2e0 100644 --- a/tests/mocha/block_json_test.js +++ b/tests/mocha/block_json_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.blockJson'); +goog.declareModuleId('Blockly.test.blockJson'); -const {Align} = goog.require('Blockly.Input'); +import {Align} from '../../build/src/core/input.js'; suite('Block JSON initialization', function() { diff --git a/tests/mocha/block_test.js b/tests/mocha/block_test.js index e342d43ef..abad7ace0 100644 --- a/tests/mocha/block_test.js +++ b/tests/mocha/block_test.js @@ -4,14 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.blocks'); +goog.declareModuleId('Blockly.test.blocks'); -const {Blocks} = goog.require('Blockly.blocks'); -const {ConnectionType} = goog.require('Blockly.ConnectionType'); -const {createDeprecationWarningStub} = goog.require('Blockly.test.helpers.warnings'); -const {createRenderedBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {ConnectionType} from '../../build/src/core/connection_type.js'; +import {createDeprecationWarningStub} from './test_helpers/warnings.js'; +import {createRenderedBlock} from './test_helpers/block_definitions.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('Blocks', function() { @@ -1990,7 +1989,7 @@ suite('Blocks', function() { // so we assert init was called to be safe. let initCalled = false; let recordUndoDuringInit; - Blocks['init_test_block'].init = function() { + Blockly.Blocks['init_test_block'].init = function() { initCalled = true; recordUndoDuringInit = eventUtils.getRecordUndo(); throw new Error(); diff --git a/tests/mocha/blocks/lists_test.js b/tests/mocha/blocks/lists_test.js index 97228bb04..166fef5ad 100644 --- a/tests/mocha/blocks/lists_test.js +++ b/tests/mocha/blocks/lists_test.js @@ -4,12 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.lists'); +goog.declareModuleId('Blockly.test.lists'); -const {runSerializationTestSuite} = goog.require('Blockly.test.helpers.serialization'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {ConnectionType} = goog.require('Blockly.ConnectionType'); -const {defineStatementBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +import {runSerializationTestSuite} from '../test_helpers/serialization.js'; +import {sharedTestSetup, sharedTestTeardown} from '../test_helpers/setup_teardown.js'; +import {ConnectionType} from '../../build/src/core/connection_type.js'; +import {defineStatementBlock} from '../test_helpers/block_definitions.js'; suite('Lists', function() { diff --git a/tests/mocha/blocks/logic_ternary_test.js b/tests/mocha/blocks/logic_ternary_test.js index 5f4c82580..a539124a6 100644 --- a/tests/mocha/blocks/logic_ternary_test.js +++ b/tests/mocha/blocks/logic_ternary_test.js @@ -4,11 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.logicTernary'); +goog.declareModuleId('Blockly.test.logicTernary'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {runSerializationTestSuite} = goog.require('Blockly.test.helpers.serialization'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {runSerializationTestSuite} from '../test_helpers/serialization.js'; +import {sharedTestSetup, sharedTestTeardown} from '../test_helpers/setup_teardown.js'; suite('Logic ternary', function() { diff --git a/tests/mocha/blocks/procedures_test.js b/tests/mocha/blocks/procedures_test.js index 6c44554e4..64d48d958 100644 --- a/tests/mocha/blocks/procedures_test.js +++ b/tests/mocha/blocks/procedures_test.js @@ -4,13 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.procedures'); +goog.declareModuleId('Blockly.test.procedures'); -goog.require('Blockly'); -goog.require('Blockly.Msg'); -const {assertCallBlockStructure, assertDefBlockStructure, createProcDefBlock, createProcCallBlock} = goog.require('Blockly.test.helpers.procedures'); -const {runSerializationTestSuite} = goog.require('Blockly.test.helpers.serialization'); -const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertCallBlockStructure, assertDefBlockStructure, createProcDefBlock, createProcCallBlock} from '../test_helpers/procedures.js'; +import {runSerializationTestSuite} from '../test_helpers/serialization.js'; +import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from '../test_helpers/setup_teardown.js'; suite('Procedures', function() { diff --git a/tests/mocha/blocks/variables_test.js b/tests/mocha/blocks/variables_test.js index e128576d0..737471220 100644 --- a/tests/mocha/blocks/variables_test.js +++ b/tests/mocha/blocks/variables_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.variables'); +goog.declareModuleId('Blockly.test.variables'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from '../test_helpers/setup_teardown.js'; suite('Variables', function() { diff --git a/tests/mocha/comment_deserialization_test.js b/tests/mocha/comment_deserialization_test.js index f3eb48dc5..a37e98986 100644 --- a/tests/mocha/comment_deserialization_test.js +++ b/tests/mocha/comment_deserialization_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.commentDeserialization'); +goog.declareModuleId('Blockly.test.commentDeserialization'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {simulateClick} = goog.require('Blockly.test.helpers.userInput'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {simulateClick} from './test_helpers/user_input.js'; suite('Comment Deserialization', function() { diff --git a/tests/mocha/comment_test.js b/tests/mocha/comment_test.js index afee012f6..e358d4fb1 100644 --- a/tests/mocha/comment_test.js +++ b/tests/mocha/comment_test.js @@ -4,11 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.comments'); +goog.declareModuleId('Blockly.test.comments'); -const {assertEventFired} = goog.require('Blockly.test.helpers.events'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {assertEventFired} from './test_helpers/events.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Comments', function() { diff --git a/tests/mocha/connection_checker_test.js b/tests/mocha/connection_checker_test.js index 523fecfcc..d86d48bfb 100644 --- a/tests/mocha/connection_checker_test.js +++ b/tests/mocha/connection_checker_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.connectionChecker'); +goog.declareModuleId('Blockly.test.connectionChecker'); -const {ConnectionType} = goog.require('Blockly.ConnectionType'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {ConnectionType} from '../../build/src/core/connection_type.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Connection checker', function() { diff --git a/tests/mocha/connection_db_test.js b/tests/mocha/connection_db_test.js index 4328d3b4b..6d7e2b363 100644 --- a/tests/mocha/connection_db_test.js +++ b/tests/mocha/connection_db_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.connectionDb'); +goog.declareModuleId('Blockly.test.connectionDb'); -const {ConnectionType} = goog.require('Blockly.ConnectionType'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {ConnectionType} from '../../build/src/core/connection_type.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Connection Database', function() { diff --git a/tests/mocha/connection_test.js b/tests/mocha/connection_test.js index 37bca1240..878fcd006 100644 --- a/tests/mocha/connection_test.js +++ b/tests/mocha/connection_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.connection'); +goog.declareModuleId('Blockly.test.connection'); -const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {defineRowBlock, defineStatementBlock, defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {defineRowBlock, defineStatementBlock, defineStackBlock} from './test_helpers/block_definitions.js'; suite('Connection', function() { diff --git a/tests/mocha/contextmenu_items_test.js b/tests/mocha/contextmenu_items_test.js index 77cae060f..ab0051a3a 100644 --- a/tests/mocha/contextmenu_items_test.js +++ b/tests/mocha/contextmenu_items_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.contextMenuItem'); +goog.declareModuleId('Blockly.test.contextMenuItem'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('Context Menu Items', function() { diff --git a/tests/mocha/cursor_test.js b/tests/mocha/cursor_test.js index 77b22470a..91514098b 100644 --- a/tests/mocha/cursor_test.js +++ b/tests/mocha/cursor_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.cursor'); +goog.declareModuleId('Blockly.test.cursor'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {ASTNode} = goog.require('Blockly.ASTNode'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {ASTNode} from '../../build/src/core/keyboard_nav/ast_node.js'; suite('Cursor', function() { diff --git a/tests/mocha/dropdowndiv_test.js b/tests/mocha/dropdowndiv_test.js index b2fd0668d..1a6cf07d8 100644 --- a/tests/mocha/dropdowndiv_test.js +++ b/tests/mocha/dropdowndiv_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.dropdown'); +goog.declareModuleId('Blockly.test.dropdown'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('DropDownDiv', function() { diff --git a/tests/mocha/event_test.js b/tests/mocha/event_test.js index 5eb391a55..30bec99ed 100644 --- a/tests/mocha/event_test.js +++ b/tests/mocha/event_test.js @@ -4,14 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.event'); +goog.declareModuleId('Blockly.test.event'); -const {ASTNode} = goog.require('Blockly.ASTNode'); -const {assertEventEquals, assertNthCallEventArgEquals, createFireChangeListenerSpy} = goog.require('Blockly.test.helpers.events'); -const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); -const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const eventUtils = goog.require('Blockly.Events.utils'); -goog.require('Blockly.WorkspaceComment'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {ASTNode} from '../../build/src/core/keyboard_nav/ast_node.js'; +import {assertEventEquals, assertNthCallEventArgEquals, createFireChangeListenerSpy} from './test_helpers/events.js'; +import {assertVariableValues} from './test_helpers/variables.js'; +import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {WorkspaceComment} from '../../build/src/core/workspace_comment.js'; suite('Events', function() { diff --git a/tests/mocha/extensions_test.js b/tests/mocha/extensions_test.js index 6c2873ff1..d848b21e6 100644 --- a/tests/mocha/extensions_test.js +++ b/tests/mocha/extensions_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.extensions'); +goog.declareModuleId('Blockly.test.extensions'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Extensions', function() { diff --git a/tests/mocha/field_angle_test.js b/tests/mocha/field_angle_test.js index d6feefbb0..172b0eeba 100644 --- a/tests/mocha/field_angle_test.js +++ b/tests/mocha/field_angle_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldAngle'); +goog.declareModuleId('Blockly.test.fieldAngle'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('Angle Fields', function() { diff --git a/tests/mocha/field_checkbox_test.js b/tests/mocha/field_checkbox_test.js index 5de565984..60a95430c 100644 --- a/tests/mocha/field_checkbox_test.js +++ b/tests/mocha/field_checkbox_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldCheckbox'); +goog.declareModuleId('Blockly.test.fieldCheckbox'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {defineRowBlock} from './test_helpers/block_definitions.js'; suite('Checkbox Fields', function() { diff --git a/tests/mocha/field_colour_test.js b/tests/mocha/field_colour_test.js index eb0389702..bf7c00f1a 100644 --- a/tests/mocha/field_colour_test.js +++ b/tests/mocha/field_colour_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldColour'); +goog.declareModuleId('Blockly.test.fieldColour'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('Colour Fields', function() { diff --git a/tests/mocha/field_dropdown_test.js b/tests/mocha/field_dropdown_test.js index 1b67525f4..b16303eaf 100644 --- a/tests/mocha/field_dropdown_test.js +++ b/tests/mocha/field_dropdown_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldDropdown'); +goog.declareModuleId('Blockly.test.fieldDropdown'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('Dropdown Fields', function() { diff --git a/tests/mocha/field_image_test.js b/tests/mocha/field_image_test.js index 4a20a790f..2e7cfb5da 100644 --- a/tests/mocha/field_image_test.js +++ b/tests/mocha/field_image_test.js @@ -4,10 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldImage'); +goog.declareModuleId('Blockly.test.fieldImage'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Image Fields', function() { diff --git a/tests/mocha/field_label_serializable_test.js b/tests/mocha/field_label_serializable_test.js index b5ba42824..928f0aa66 100644 --- a/tests/mocha/field_label_serializable_test.js +++ b/tests/mocha/field_label_serializable_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldLabelSerialization'); +goog.declareModuleId('Blockly.test.fieldLabelSerialization'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js'; suite('Label Serializable Fields', function() { diff --git a/tests/mocha/field_label_test.js b/tests/mocha/field_label_test.js index 62f088b96..88a18cd1f 100644 --- a/tests/mocha/field_label_test.js +++ b/tests/mocha/field_label_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldLabel'); +goog.declareModuleId('Blockly.test.fieldLabel'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {createTestBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {createTestBlock} from './test_helpers/block_definitions.js'; suite('Label Fields', function() { diff --git a/tests/mocha/field_multilineinput_test.js b/tests/mocha/field_multilineinput_test.js index a94a1b945..594dc863d 100644 --- a/tests/mocha/field_multilineinput_test.js +++ b/tests/mocha/field_multilineinput_test.js @@ -4,12 +4,18 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldMultiline'); +goog.declareModuleId('Blockly.test.fieldMultiline'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {runCodeGenerationTestSuites} = goog.require('Blockly.test.helpers.codeGeneration'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {runCodeGenerationTestSuites} from './test_helpers/code_generation.js'; +const {dartGenerator} = goog.require('Blockly.Dart'); +const {javascriptGenerator} = goog.require('Blockly.JavaScript'); +const {luaGenerator} = goog.require('Blockly.Lua'); +const {phpGenerator} = goog.require('Blockly.PHP'); +const {pythonGenerator} = goog.require('Blockly.Python'); suite('Multiline Input Fields', function() { diff --git a/tests/mocha/field_number_test.js b/tests/mocha/field_number_test.js index b0d002399..10176cf22 100644 --- a/tests/mocha/field_number_test.js +++ b/tests/mocha/field_number_test.js @@ -4,12 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldNumber'); +goog.declareModuleId('Blockly.test.fieldNumber'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {runTestCases} = goog.require('Blockly.test.helpers.common'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {defineRowBlock} from './test_helpers/block_definitions.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {runTestCases} from './test_helpers/common.js'; suite('Number Fields', function() { diff --git a/tests/mocha/field_registry_test.js b/tests/mocha/field_registry_test.js index 394081365..7c2378d39 100644 --- a/tests/mocha/field_registry_test.js +++ b/tests/mocha/field_registry_test.js @@ -4,10 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldRegistry'); +goog.declareModuleId('Blockly.test.fieldRegistry'); -const {createDeprecationWarningStub} = goog.require('Blockly.test.helpers.warnings'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {createDeprecationWarningStub} from './test_helpers/warnings.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Field Registry', function() { diff --git a/tests/mocha/field_test.js b/tests/mocha/field_test.js index 4d1887aa0..ca5cad5f5 100644 --- a/tests/mocha/field_test.js +++ b/tests/mocha/field_test.js @@ -4,10 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldTest'); +goog.declareModuleId('Blockly.test.fieldTest'); -const {addBlockTypeToCleanup, addMessageToCleanup, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {createDeprecationWarningStub} = goog.require('Blockly.test.helpers.warnings'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {addBlockTypeToCleanup, addMessageToCleanup, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {createDeprecationWarningStub} from './test_helpers/warnings.js'; suite('Abstract Fields', function() { diff --git a/tests/mocha/field_textinput_test.js b/tests/mocha/field_textinput_test.js index f46afe09b..f37e6d885 100644 --- a/tests/mocha/field_textinput_test.js +++ b/tests/mocha/field_textinput_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldTextInput'); +goog.declareModuleId('Blockly.test.fieldTextInput'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('Text Input Fields', function() { diff --git a/tests/mocha/field_variable_test.js b/tests/mocha/field_variable_test.js index 94337d0cb..5872f12bc 100644 --- a/tests/mocha/field_variable_test.js +++ b/tests/mocha/field_variable_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.fieldVariable'); +goog.declareModuleId('Blockly.test.fieldVariable'); -const {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} = goog.require('Blockly.test.helpers.fields'); -const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js'; +import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js'; suite('Variable Fields', function() { diff --git a/tests/mocha/flyout_test.js b/tests/mocha/flyout_test.js index 8fbc38659..40c584281 100644 --- a/tests/mocha/flyout_test.js +++ b/tests/mocha/flyout_test.js @@ -4,10 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.flyout'); +goog.declareModuleId('Blockly.test.flyout'); -const {defineStackBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {getBasicToolbox, getChildItem, getCollapsibleItem, getDeeplyNestedJSON, getInjectedToolbox, getNonCollapsibleItem, getProperSimpleJson, getSeparator, getSimpleJson, getXmlArray} = goog.require('Blockly.test.helpers.toolboxDefinitions'); +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {defineStackBlock} from './test_helpers/block_definitions.js'; +import {getBasicToolbox, getChildItem, getCollapsibleItem, getDeeplyNestedJSON, getInjectedToolbox, getNonCollapsibleItem, getProperSimpleJson, getSeparator, getSimpleJson, getXmlArray} from './test_helpers/toolbox_definitions.js'; suite('Flyout', function() { diff --git a/tests/mocha/generator_test.js b/tests/mocha/generator_test.js index 3fd2fa24b..321d5f1cb 100644 --- a/tests/mocha/generator_test.js +++ b/tests/mocha/generator_test.js @@ -4,14 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.generator'); +goog.declareModuleId('Blockly.test.generator'); +import * as Blockly from '../../build/src/core/blockly.js'; const {dartGenerator} = goog.require('Blockly.Dart'); -const {javaScriptGenerator} = goog.require('Blockly.JavaScript'); +const {javascriptGenerator} = goog.require('Blockly.JavaScript'); const {luaGenerator} = goog.require('Blockly.Lua'); const {phpGenerator} = goog.require('Blockly.PHP'); const {pythonGenerator} = goog.require('Blockly.Python'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Generator', function() { diff --git a/tests/mocha/gesture_test.js b/tests/mocha/gesture_test.js index bc97c3b5f..3efbb1acc 100644 --- a/tests/mocha/gesture_test.js +++ b/tests/mocha/gesture_test.js @@ -4,13 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.gesture'); +goog.declareModuleId('Blockly.test.gesture'); -const {assertEventFired, assertEventNotFired} = goog.require('Blockly.test.helpers.events'); -const {defineBasicBlockWithField} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {dispatchPointerEvent} = goog.require('Blockly.test.helpers.userInput'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {assertEventFired, assertEventNotFired} from './test_helpers/events.js'; +import {defineBasicBlockWithField} from './test_helpers/block_definitions.js'; +import {dispatchPointerEvent} from './test_helpers/user_input.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Gesture', function() { diff --git a/tests/mocha/input_test.js b/tests/mocha/input_test.js index cd6997212..eb82738b1 100644 --- a/tests/mocha/input_test.js +++ b/tests/mocha/input_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.input'); +goog.declareModuleId('Blockly.test.input'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Inputs', function() { diff --git a/tests/mocha/insertion_marker_test.js b/tests/mocha/insertion_marker_test.js index 909212f9e..c03fbafa3 100644 --- a/tests/mocha/insertion_marker_test.js +++ b/tests/mocha/insertion_marker_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.insertionMarker'); +goog.declareModuleId('Blockly.test.insertionMarker'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('InsertionMarkers', function() { diff --git a/tests/mocha/jso_deserialization_test.js b/tests/mocha/jso_deserialization_test.js index 7f89f1189..a476436fb 100644 --- a/tests/mocha/jso_deserialization_test.js +++ b/tests/mocha/jso_deserialization_test.js @@ -4,11 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.jsoDeserialization'); +goog.declareModuleId('Blockly.test.jsoDeserialization'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {assertEventFired} = goog.require('Blockly.test.helpers.events'); -const eventUtils = goog.require('Blockly.Events.utils'); +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {assertEventFired} from './test_helpers/events.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; suite('JSO Deserialization', function() { diff --git a/tests/mocha/jso_serialization_test.js b/tests/mocha/jso_serialization_test.js index d4abd5ffb..810f5f295 100644 --- a/tests/mocha/jso_serialization_test.js +++ b/tests/mocha/jso_serialization_test.js @@ -4,10 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.jsoSerialization'); +goog.declareModuleId('Blockly.test.jsoSerialization'); -const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {defineRowBlock, defineStackBlock, defineStatementBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {defineRowBlock, defineStackBlock, defineStatementBlock} from './test_helpers/block_definitions.js'; suite('JSO Serialization', function() { diff --git a/tests/mocha/json_test.js b/tests/mocha/json_test.js index 3e20926cb..383b49130 100644 --- a/tests/mocha/json_test.js +++ b/tests/mocha/json_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.json'); +goog.declareModuleId('Blockly.test.json'); -const {addMessageToCleanup, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {assertNoWarnings, assertWarnings} = goog.require('Blockly.test.helpers.warnings'); +import {addMessageToCleanup, sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {assertNoWarnings, assertWarnings} from './test_helpers/warnings.js'; suite('JSON Block Definitions', function() { diff --git a/tests/mocha/keydown_test.js b/tests/mocha/keydown_test.js index 8ef2bd2a6..8fc480ba2 100644 --- a/tests/mocha/keydown_test.js +++ b/tests/mocha/keydown_test.js @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.keydown'); +goog.declareModuleId('Blockly.test.keydown'); -const {createKeyDownEvent} = goog.require('Blockly.test.helpers.userInput'); -const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {createKeyDownEvent} from './test_helpers/user_input.js'; +import {defineStackBlock} from './test_helpers/block_definitions.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Key Down', function() { diff --git a/tests/mocha/metrics_test.js b/tests/mocha/metrics_test.js index 5fcc0b69c..9e7eb001f 100644 --- a/tests/mocha/metrics_test.js +++ b/tests/mocha/metrics_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.metrics'); +goog.declareModuleId('Blockly.test.metrics'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Metrics', function() { diff --git a/tests/mocha/mutator_test.js b/tests/mocha/mutator_test.js index f08d9879c..602dbbeb2 100644 --- a/tests/mocha/mutator_test.js +++ b/tests/mocha/mutator_test.js @@ -5,10 +5,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.mutator'); +goog.declareModuleId('Blockly.test.mutator'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {createRenderedBlock, defineMutatorBlocks} = goog.require('Blockly.test.helpers.blockDefinitions'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {createRenderedBlock, defineMutatorBlocks} from './test_helpers/block_definitions.js'; suite('Mutator', function() { diff --git a/tests/mocha/names_test.js b/tests/mocha/names_test.js index 705a3ff9b..e9a8195be 100644 --- a/tests/mocha/names_test.js +++ b/tests/mocha/names_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.names'); +goog.declareModuleId('Blockly.test.names'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Names', function() { diff --git a/tests/mocha/registry_test.js b/tests/mocha/registry_test.js index b6fabfea1..b6bb66086 100644 --- a/tests/mocha/registry_test.js +++ b/tests/mocha/registry_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.registry'); +goog.declareModuleId('Blockly.test.registry'); -const {assertWarnings} = goog.require('Blockly.test.helpers.warnings'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {assertWarnings} from './test_helpers/warnings.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Registry', function() { diff --git a/tests/mocha/serializer_test.js b/tests/mocha/serializer_test.js index 9ddb4a90e..19f49c993 100644 --- a/tests/mocha/serializer_test.js +++ b/tests/mocha/serializer_test.js @@ -4,10 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.serialization'); +goog.declareModuleId('Blockly.test.serialization'); -const {TestCase, TestSuite, runTestCases, runTestSuites} = goog.require('Blockly.test.helpers.common'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import * as Blockly from '../../build/src/core/blockly.js'; +import {TestCase, TestSuite, runTestCases, runTestSuites} from './test_helpers/common.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; // TODO: Move this into samples as part of the dev-tools package. diff --git a/tests/mocha/shortcut_registry_test.js b/tests/mocha/shortcut_registry_test.js index 8d38ebff9..c41fa1910 100644 --- a/tests/mocha/shortcut_registry_test.js +++ b/tests/mocha/shortcut_registry_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.shortcutRegistry'); +goog.declareModuleId('Blockly.test.shortcutRegistry'); -const {createKeyDownEvent} = goog.require('Blockly.test.helpers.userInput'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {createKeyDownEvent} from './test_helpers/user_input.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Keyboard Shortcut Registry Test', function() { diff --git a/tests/mocha/test_helpers/block_definitions.js b/tests/mocha/test_helpers/block_definitions.js index a30d7defe..213075a74 100644 --- a/tests/mocha/test_helpers/block_definitions.js +++ b/tests/mocha/test_helpers/block_definitions.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.blockDefinitions'); +goog.declareModuleId('Blockly.test.helpers.blockDefinitions'); -function defineStackBlock(name = 'stack_block') { +export function defineStackBlock(name = 'stack_block') { Blockly.defineBlocksWithJsonArray([{ "type": name, "message0": "", @@ -15,9 +15,8 @@ function defineStackBlock(name = 'stack_block') { "nextStatement": null, }]); } -exports.defineStackBlock = defineStackBlock; -function defineRowBlock(name = 'row_block') { +export function defineRowBlock(name = 'row_block') { Blockly.defineBlocksWithJsonArray([{ "type": name, "message0": "%1", @@ -30,9 +29,8 @@ function defineRowBlock(name = 'row_block') { "output": null, }]); } -exports.defineRowBlock = defineRowBlock; -function defineStatementBlock(name = 'statement_block') { +export function defineStatementBlock(name = 'statement_block') { Blockly.defineBlocksWithJsonArray([{ "type": name, "message0": "%1", @@ -49,9 +47,8 @@ function defineStatementBlock(name = 'statement_block') { "helpUrl": "", }]); } -exports.defineStatementBlock = defineStatementBlock; -function defineBasicBlockWithField(name = 'test_field_block') { +export function defineBasicBlockWithField(name = 'test_field_block') { Blockly.defineBlocksWithJsonArray([{ "type": name, "message0": "%1", @@ -64,9 +61,8 @@ function defineBasicBlockWithField(name = 'test_field_block') { "output": null, }]); } -exports.defineBasicBlockWithField = defineBasicBlockWithField; -function defineMutatorBlocks() { +export function defineMutatorBlocks() { Blockly.defineBlocksWithJsonArray([ { 'type': 'xml_block', @@ -158,9 +154,8 @@ function defineMutatorBlocks() { }; Blockly.Extensions.registerMutator('jso_mutator', jsoMutator); } -exports.defineMutatorBlocks = defineMutatorBlocks; -function createTestBlock() { +export function createTestBlock() { return { 'id': 'test', 'rendered': false, @@ -174,12 +169,10 @@ function createTestBlock() { 'updateVarName': Blockly.Block.prototype.updateVarName, }; } -exports.createTestBlock = createTestBlock; -function createRenderedBlock(workspaceSvg, type) { +export function createRenderedBlock(workspaceSvg, type) { const block = workspaceSvg.newBlock(type); block.initSvg(); block.render(); return block; } -exports.createRenderedBlock = createRenderedBlock; diff --git a/tests/mocha/test_helpers/code_generation.js b/tests/mocha/test_helpers/code_generation.js index 72d520c7f..82358da63 100644 --- a/tests/mocha/test_helpers/code_generation.js +++ b/tests/mocha/test_helpers/code_generation.js @@ -5,9 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.codeGeneration'); +goog.declareModuleId('Blockly.test.helpers.codeGeneration'); -const {runTestSuites} = goog.require('Blockly.test.helpers.common'); +import {runTestSuites} from './common.js'; /** @@ -15,7 +15,7 @@ const {runTestSuites} = goog.require('Blockly.test.helpers.common'); * @implements {TestCase} * @record */ -class CodeGenerationTestCase { +export class CodeGenerationTestCase { /** * Class for a code generation test case. */ @@ -43,14 +43,13 @@ class CodeGenerationTestCase { */ createBlock(workspace) {} } -exports.CodeGenerationTestCase = CodeGenerationTestCase; /** * Code generation test suite. * @extends {TestSuite} * @record */ -class CodeGenerationTestSuite { +export class CodeGenerationTestSuite { /** * Class for a code generation test suite. */ @@ -61,7 +60,6 @@ class CodeGenerationTestSuite { this.generator; } } -exports.CodeGenerationTestSuite = CodeGenerationTestSuite; /** * Returns mocha test callback for code generation based on provided @@ -102,7 +100,7 @@ const createCodeGenerationTestFn_ = (generator) => { * Runs blockToCode test suites. * @param {!Array} testSuites The test suites to run. */ -const runCodeGenerationTestSuites = (testSuites) => { +export const runCodeGenerationTestSuites = (testSuites) => { /** * Creates function used to generate mocha test callback. * @param {!CodeGenerationTestSuite} suiteInfo The test suite information. @@ -115,4 +113,3 @@ const runCodeGenerationTestSuites = (testSuites) => { runTestSuites(testSuites, createTestFn); }; -exports.runCodeGenerationTestSuites = runCodeGenerationTestSuites; diff --git a/tests/mocha/test_helpers/common.js b/tests/mocha/test_helpers/common.js index fcb61021a..8e705b0fc 100644 --- a/tests/mocha/test_helpers/common.js +++ b/tests/mocha/test_helpers/common.js @@ -4,13 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.common'); +goog.declareModuleId('Blockly.test.helpers.common'); /** * Test case configuration. * @record */ -class TestCase { +export class TestCase { /** * Class for a test case configuration. */ @@ -31,7 +31,6 @@ class TestCase { this.only; } } -exports.TestCase = TestCase; /** * Test suite configuration. @@ -39,7 +38,7 @@ exports.TestCase = TestCase; * @template {TestCase} T * @template {TestSuite} U */ -class TestSuite { +export class TestSuite { /** * Class for a test suite configuration. */ @@ -68,7 +67,6 @@ class TestSuite { this.only; } } -exports.TestSuite = TestSuite; /** * Runs provided test cases. @@ -77,14 +75,13 @@ exports.TestSuite = TestSuite; * @param {function(T):Function} createTestCallback Creates test * callback using given test case. */ -function runTestCases(testCases, createTestCallback) { +export function runTestCases(testCases, createTestCallback) { testCases.forEach((testCase) => { let testCall = (testCase.skip ? test.skip : test); testCall = (testCase.only ? test.only : testCall); testCall(testCase.title, createTestCallback(testCase)); }); } -exports.runTestCases = runTestCases; /** * Runs provided test suite. @@ -95,7 +92,7 @@ exports.runTestCases = runTestCases; * } createTestCaseCallback Creates test case callback using given test * suite. */ -function runTestSuites(testSuites, createTestCaseCallback) { +export function runTestSuites(testSuites, createTestCaseCallback) { testSuites.forEach((testSuite) => { let suiteCall = (testSuite.skip ? suite.skip : suite); suiteCall = (testSuite.only ? suite.only : suiteCall); @@ -109,4 +106,3 @@ function runTestSuites(testSuites, createTestCaseCallback) { }); }); } -exports.runTestSuites = runTestSuites; diff --git a/tests/mocha/test_helpers/events.js b/tests/mocha/test_helpers/events.js index e69573318..ba1b3f4f8 100644 --- a/tests/mocha/test_helpers/events.js +++ b/tests/mocha/test_helpers/events.js @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.events'); +goog.declareModuleId('Blockly.test.helpers.events'); /** @@ -13,10 +13,9 @@ goog.module('Blockly.test.helpers.events'); * calls on. * @return {!SinonSpy} The created spy. */ -function createFireChangeListenerSpy(workspace) { +export function createFireChangeListenerSpy(workspace) { return sinon.spy(workspace, 'fireChangeListener'); } -exports.createFireChangeListenerSpy = createFireChangeListenerSpy; /** * Asserts whether the given xml property has the expected property. @@ -75,7 +74,7 @@ function isXmlProperty_(key) { * @param {boolean=} [isUiEvent=false] Whether the event is a UI event. * @param {string=} message Optional message to prepend assert messages. */ -function assertEventEquals(event, expectedType, +export function assertEventEquals(event, expectedType, expectedWorkspaceId, expectedBlockId, expectedProperties, isUiEvent = false, message) { let prependMessage = message ? message + ' ' : ''; prependMessage += 'Event fired '; @@ -107,7 +106,6 @@ function assertEventEquals(event, expectedType, chai.assert.isFalse(event.isUiEvent); } } -exports.assertEventEquals = assertEventEquals; /** * Asserts that an event with the given values was fired. @@ -119,7 +117,7 @@ exports.assertEventEquals = assertEventEquals; * @param {string} expectedWorkspaceId Expected workspace id of event fired. * @param {?string=} expectedBlockId Expected block id of event fired. */ -function assertEventFired(spy, instanceType, expectedProperties, +export function assertEventFired(spy, instanceType, expectedProperties, expectedWorkspaceId, expectedBlockId) { expectedProperties = Object.assign({ workspaceId: expectedWorkspaceId, @@ -129,7 +127,6 @@ function assertEventFired(spy, instanceType, expectedProperties, sinon.match.instanceOf(instanceType).and(sinon.match(expectedProperties)); sinon.assert.calledWith(spy, expectedEvent); } -exports.assertEventFired = assertEventFired; /** * Asserts that an event with the given values was not fired. @@ -141,7 +138,7 @@ exports.assertEventFired = assertEventFired; * @param {string=} expectedWorkspaceId Expected workspace id of event fired. * @param {?string=} expectedBlockId Expected block id of event fired. */ -function assertEventNotFired(spy, instanceType, expectedProperties, +export function assertEventNotFired(spy, instanceType, expectedProperties, expectedWorkspaceId, expectedBlockId) { expectedProperties.type = instanceType.prototype.type; if (expectedWorkspaceId !== undefined) { @@ -154,7 +151,6 @@ function assertEventNotFired(spy, instanceType, expectedProperties, sinon.match.instanceOf(instanceType).and(sinon.match(expectedProperties)); sinon.assert.neverCalledWith(spy, expectedEvent); } -exports.assertEventNotFired = assertEventNotFired; /** * Filters out xml properties from given object based on key. @@ -189,7 +185,7 @@ function splitByXmlProperties_(properties) { * @param {string} expectedWorkspaceId Expected workspace id of event fired. * @param {?string=} expectedBlockId Expected block id of event fired. */ -function assertNthCallEventArgEquals(spy, n, instanceType, expectedProperties, +export function assertNthCallEventArgEquals(spy, n, instanceType, expectedProperties, expectedWorkspaceId, expectedBlockId) { const nthCall = spy.getCall(n); const splitProperties = splitByXmlProperties_(expectedProperties); @@ -201,4 +197,3 @@ function assertNthCallEventArgEquals(spy, n, instanceType, expectedProperties, const eventArg = nthCall.firstArg; assertXmlProperties_(eventArg, xmlProperties); } -exports.assertNthCallEventArgEquals = assertNthCallEventArgEquals; diff --git a/tests/mocha/test_helpers/fields.js b/tests/mocha/test_helpers/fields.js index dd89e55fa..8d796d4a6 100644 --- a/tests/mocha/test_helpers/fields.js +++ b/tests/mocha/test_helpers/fields.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.fields'); +goog.declareModuleId('Blockly.test.helpers.fields'); -const {runTestCases, TestCase} = goog.require('Blockly.test.helpers.common'); +import {runTestCases, TestCase} from './common.js'; /** @@ -14,7 +14,7 @@ const {runTestCases, TestCase} = goog.require('Blockly.test.helpers.common'); * @implements {TestCase} * @record */ -class FieldValueTestCase { +export class FieldValueTestCase { /** * Class for a a field value test case. */ @@ -39,14 +39,13 @@ class FieldValueTestCase { this.errMsgMatcher; } } -exports.FieldValueTestCase = FieldValueTestCase; /** * Field creation test case. * @extends {FieldValueTestCase} * @record */ -class FieldCreationTestCase { +export class FieldCreationTestCase { /** * Class for a field creation test case. */ @@ -61,7 +60,6 @@ class FieldCreationTestCase { this.json; } } -exports.FieldCreationTestCase = FieldCreationTestCase; /** * Assert a field's value is the same as the expected value. @@ -69,7 +67,7 @@ exports.FieldCreationTestCase = FieldCreationTestCase; * @param {*} expectedValue The expected value. * @param {string=} expectedText The expected text. */ -function assertFieldValue(field, expectedValue, expectedText = undefined) { +export function assertFieldValue(field, expectedValue, expectedText = undefined) { const actualValue = field.getValue(); const actualText = field.getText(); if (expectedText === undefined) { @@ -78,7 +76,6 @@ function assertFieldValue(field, expectedValue, expectedText = undefined) { chai.assert.equal(actualValue, expectedValue, 'Value'); chai.assert.equal(actualText, expectedText, 'Text'); } -exports.assertFieldValue = assertFieldValue; /** * Runs provided creation test cases. @@ -145,7 +142,7 @@ function runCreationTestsAssertThrows_(testCases, creation) { * @param {function(!FieldCreationTestCase=)=} customCreateWithJs Custom * creation function to use in tests. */ -function runConstructorSuiteTests(TestedField, validValueTestCases, +export function runConstructorSuiteTests(TestedField, validValueTestCases, invalidValueTestCases, validRunAssertField, assertFieldDefault, customCreateWithJs) { suite('Constructor', function() { @@ -182,7 +179,6 @@ function runConstructorSuiteTests(TestedField, validValueTestCases, runCreationTests_(validValueTestCases, validRunAssertField, createWithJs); }); } -exports.runConstructorSuiteTests = runConstructorSuiteTests; /** * Runs suite of tests for fromJson creation of specified field. @@ -200,7 +196,7 @@ exports.runConstructorSuiteTests = runConstructorSuiteTests; * @param {function(!FieldCreationTestCase=)=} customCreateWithJson Custom * creation function to use in tests. */ -function runFromJsonSuiteTests(TestedField, validValueTestCases, +export function runFromJsonSuiteTests(TestedField, validValueTestCases, invalidValueTestCases, validRunAssertField, assertFieldDefault, customCreateWithJson) { suite('fromJson', function() { @@ -237,7 +233,6 @@ function runFromJsonSuiteTests(TestedField, validValueTestCases, runCreationTests_(validValueTestCases, validRunAssertField, createWithJson); }); } -exports.runFromJsonSuiteTests = runFromJsonSuiteTests; /** * Runs tests for setValue calls. @@ -250,7 +245,7 @@ exports.runFromJsonSuiteTests = runFromJsonSuiteTests; * @param {string=} invalidRunExpectedText Expected text for field after invalid * call to setValue. */ -function runSetValueTests(validValueTestCases, invalidValueTestCases, +export function runSetValueTests(validValueTestCases, invalidValueTestCases, invalidRunExpectedValue, invalidRunExpectedText) { /** * Creates test callback for invalid setValue test. @@ -279,4 +274,3 @@ function runSetValueTests(validValueTestCases, invalidValueTestCases, runTestCases(invalidValueTestCases, createInvalidSetValueTestCallback); runTestCases(validValueTestCases, createValidSetValueTestCallback); } -exports.runSetValueTests = runSetValueTests; diff --git a/tests/mocha/test_helpers/procedures.js b/tests/mocha/test_helpers/procedures.js index 23843c9f6..9358ade73 100644 --- a/tests/mocha/test_helpers/procedures.js +++ b/tests/mocha/test_helpers/procedures.js @@ -3,9 +3,9 @@ * Copyright 2020 Google LLC * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.procedures'); +goog.declareModuleId('Blockly.test.helpers.procedures'); -const {ConnectionType} = goog.require('Blockly.ConnectionType'); +import {ConnectionType} from '../../../build/src/core/connection_type.js'; /** @@ -55,7 +55,7 @@ function assertCallBlockArgsStructure(callBlock, args) { * @param {boolean=} hasStatements If we expect the procedure def to have a * statement input or not. */ -function assertDefBlockStructure(defBlock, hasReturn = false, +export function assertDefBlockStructure(defBlock, hasReturn = false, args = [], varIds = [], hasStatements = true) { if (hasStatements) { chai.assert.isNotNull(defBlock.getInput('STACK'), @@ -82,7 +82,6 @@ function assertDefBlockStructure(defBlock, hasReturn = false, chai.assert.sameOrderedMembers(defBlock.getVars(), args); assertBlockVarModels(defBlock, varIds); } -exports.assertDefBlockStructure = assertDefBlockStructure; /** * Asserts that the procedure call block has the expected inputs and @@ -92,7 +91,7 @@ exports.assertDefBlockStructure = assertDefBlockStructure; * @param {Array=} varIds An array of variable ids. * @param {string=} name The name we expect the caller to have. */ -function assertCallBlockStructure( +export function assertCallBlockStructure( callBlock, args = [], varIds = [], name = undefined) { if (args.length) { chai.assert.include(callBlock.toString(), 'with'); @@ -106,7 +105,6 @@ function assertCallBlockStructure( chai.assert(callBlock.getFieldValue('NAME'), name); } } -exports.assertCallBlockStructure = assertCallBlockStructure; /** * Creates procedure definition block using domToBlock call. @@ -116,7 +114,7 @@ exports.assertCallBlockStructure = assertCallBlockStructure; * @param {Array=} args An array of argument names. * @return {Blockly.Block} The created block. */ -function createProcDefBlock( +export function createProcDefBlock( workspace, hasReturn = false, args = []) { const type = hasReturn ? 'procedures_defreturn' : 'procedures_defnoreturn'; @@ -130,7 +128,6 @@ function createProcDefBlock( ''; return Blockly.Xml.domToBlock(Blockly.Xml.textToDom(xml), workspace); } -exports.createProcDefBlock = createProcDefBlock; /** * Creates procedure call block using domToBlock call. @@ -139,7 +136,7 @@ exports.createProcDefBlock = createProcDefBlock; * has return. * @return {Blockly.Block} The created block. */ -function createProcCallBlock( +export function createProcCallBlock( workspace, hasReturn = false) { const type = hasReturn ? 'procedures_callreturn' : 'procedures_callnoreturn'; @@ -149,4 +146,3 @@ function createProcCallBlock( '' ), workspace); } -exports.createProcCallBlock = createProcCallBlock; diff --git a/tests/mocha/test_helpers/serialization.js b/tests/mocha/test_helpers/serialization.js index c8b90ba7f..cc076bfc0 100644 --- a/tests/mocha/test_helpers/serialization.js +++ b/tests/mocha/test_helpers/serialization.js @@ -4,16 +4,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.serialization'); +goog.declareModuleId('Blockly.test.helpers.serialization'); -const {runTestCases} = goog.require('Blockly.test.helpers.common'); +import {runTestCases} from './common.js'; /** * Serialization test case. * @implements {TestCase} * @record */ -class SerializationTestCase { +export class SerializationTestCase { /** * Class for a block serialization test case. */ @@ -45,13 +45,12 @@ class SerializationTestCase { */ assertBlockStructure(block) {} } -exports.SerializationTestCase = SerializationTestCase; /** * Runs serialization test suite. * @param {!Array} testCases The test cases to run. */ -const runSerializationTestSuite = (testCases) => { +export const runSerializationTestSuite = (testCases) => { /** * Creates test callback for xmlToBlock test. * @param {!SerializationTestCase} testCase The test case information. @@ -129,4 +128,3 @@ const runSerializationTestSuite = (testCases) => { }); }); }; -exports.runSerializationTestSuite = runSerializationTestSuite; diff --git a/tests/mocha/test_helpers/setup_teardown.js b/tests/mocha/test_helpers/setup_teardown.js index c49c40842..8d318af4d 100644 --- a/tests/mocha/test_helpers/setup_teardown.js +++ b/tests/mocha/test_helpers/setup_teardown.js @@ -4,11 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.setupTeardown'); - -const eventUtils = goog.require('Blockly.Events.utils'); -const {Blocks} = goog.require('Blockly.blocks'); +goog.declareModuleId('Blockly.test.helpers.setupTeardown'); +import * as eventUtils from '../../../build/src/core/events/utils.js'; /** * Safely disposes of Blockly workspace, logging any errors. @@ -16,7 +14,7 @@ const {Blocks} = goog.require('Blockly.blocks'); * using workspaceTeardown.call(this). * @param {!Blockly.Workspace} workspace The workspace to dispose. */ -function workspaceTeardown(workspace) { +export function workspaceTeardown(workspace) { try { this.clock.runAll(); // Run all queued setTimeout calls. workspace.dispose(); @@ -26,7 +24,6 @@ function workspaceTeardown(workspace) { console.error(testRef.fullTitle() + '\n', e); } } -exports.workspaceTeardown = workspaceTeardown; /** * Creates stub for Blockly.Events.fire that advances the clock forward after @@ -53,10 +50,9 @@ function createEventsFireStubFireImmediately_(clock) { * sharedTestSetup. * @param {string} message The message to add to shared cleanup object. */ -function addMessageToCleanup(sharedCleanupObj, message) { +export function addMessageToCleanup(sharedCleanupObj, message) { sharedCleanupObj.messagesCleanup_.push(message); } -exports.addMessageToCleanup = addMessageToCleanup; /** * Adds block type to shared cleanup object so that it is cleaned from @@ -65,10 +61,9 @@ exports.addMessageToCleanup = addMessageToCleanup; * sharedTestSetup. * @param {string} blockType The block type to add to shared cleanup object. */ -function addBlockTypeToCleanup(sharedCleanupObj, blockType) { +export function addBlockTypeToCleanup(sharedCleanupObj, blockType) { sharedCleanupObj.blockTypesCleanup_.push(blockType); } -exports.addBlockTypeToCleanup = addBlockTypeToCleanup; /** * Wraps Blockly.defineBlocksWithJsonArray using stub in order to keep track of @@ -111,7 +106,7 @@ function wrapDefineBlocksWithJsonArrayWithCleanup_(sharedCleanupObj) { * @param {Object} options Options to enable/disable setup * of certain stubs. */ -function sharedTestSetup(options = {}) { +export function sharedTestSetup(options = {}) { this.sharedSetupCalled_ = true; // Sandbox created for greater control when certain stubs are cleared. this.sharedSetupSandbox_ = sinon.createSandbox(); @@ -128,14 +123,13 @@ function sharedTestSetup(options = {}) { this.messagesCleanup_ = this.sharedCleanup.messagesCleanup_; wrapDefineBlocksWithJsonArrayWithCleanup_(this.sharedCleanup); } -exports.sharedTestSetup = sharedTestSetup; /** * Shared cleanup method that clears up pending setTimeout calls, disposes of * workspace, and resets global variables. Should be called in setup of * outermost suite using sharedTestTeardown.call(this). */ -function sharedTestTeardown() { +export function sharedTestTeardown() { const testRef = this.currentTest || this.test; if (!this.sharedSetupCalled_) { console.error('"' + testRef.fullTitle() + '" did not call sharedTestSetup'); @@ -173,7 +167,7 @@ function sharedTestTeardown() { const blockTypes = this.sharedCleanup.blockTypesCleanup_; for (let i = 0; i < blockTypes.length; i++) { - delete Blocks[blockTypes[i]]; + delete Blockly.Blocks[blockTypes[i]]; } const messages = this.sharedCleanup.messagesCleanup_; for (let i = 0; i < messages.length; i++) { @@ -183,7 +177,6 @@ function sharedTestTeardown() { Blockly.WidgetDiv.testOnly_setDiv(null); } } -exports.sharedTestTeardown = sharedTestTeardown; /** * Creates stub for Blockly.utils.genUid that returns the provided id or ids. @@ -194,7 +187,7 @@ exports.sharedTestTeardown = sharedTestTeardown; * that value. * @return {!SinonStub} The created stub. */ -function createGenUidStubWithReturns(returnIds) { +export function createGenUidStubWithReturns(returnIds) { const stub = sinon.stub(Blockly.utils.idGenerator.TEST_ONLY, "genUid"); if (Array.isArray(returnIds)) { for (let i = 0; i < returnIds.length; i++) { @@ -205,4 +198,3 @@ function createGenUidStubWithReturns(returnIds) { } return stub; } -exports.createGenUidStubWithReturns = createGenUidStubWithReturns; diff --git a/tests/mocha/test_helpers/toolbox_definitions.js b/tests/mocha/test_helpers/toolbox_definitions.js index ee7ff576f..0a7f2b9ef 100644 --- a/tests/mocha/test_helpers/toolbox_definitions.js +++ b/tests/mocha/test_helpers/toolbox_definitions.js @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.toolboxDefinitions'); +goog.declareModuleId('Blockly.test.helpers.toolboxDefinitions'); /** @@ -12,7 +12,7 @@ goog.module('Blockly.test.helpers.toolboxDefinitions'); * @return {Blockly.utils.toolbox.ToolboxJson} The array holding information * for a toolbox. */ -function getCategoryJSON() { +export function getCategoryJSON() { return {"contents": [ { "kind": "CATEGORY", @@ -42,14 +42,13 @@ function getCategoryJSON() { "name": "Second", }]}; } -exports.getCategoryJSON = getCategoryJSON; /** * Get JSON for a simple toolbox. * @return {Blockly.utils.toolbox.ToolboxJson} The array holding information * for a simple toolbox. */ -function getSimpleJson() { +export function getSimpleJson() { return {"contents": [ { "kind": "BLOCK", @@ -83,9 +82,8 @@ function getSimpleJson() { }, ]}; } -exports.getSimpleJson = getSimpleJson; -function getProperSimpleJson() { +export function getProperSimpleJson() { return { "contents": [ { @@ -128,14 +126,13 @@ function getProperSimpleJson() { }, ]}; } -exports.getProperSimpleJson = getProperSimpleJson; /** * Get JSON for a toolbox that contains categories that contain categories. * @return {Blockly.utils.toolbox.ToolboxJson} The array holding information * for a toolbox. */ -function getDeeplyNestedJSON() { +export function getDeeplyNestedJSON() { return {"contents": [ { "kind": "CATEGORY", @@ -173,13 +170,12 @@ function getDeeplyNestedJSON() { "name": "Second", }]}; } -exports.getDeeplyNestedJSON = getDeeplyNestedJSON; /** * Get an array filled with xml elements. * @return {Array} Array holding xml elements for a toolbox. */ -function getXmlArray() { +export function getXmlArray() { const block = Blockly.Xml.textToDom( ` NEQ @@ -199,9 +195,8 @@ function getXmlArray() { const label = Blockly.Xml.textToDom(''); return [block, separator, button, label]; } -exports.getXmlArray = getXmlArray; -function getInjectedToolbox() { +export function getInjectedToolbox() { /** * Category: First * sep @@ -221,18 +216,16 @@ function getInjectedToolbox() { }); return workspace.getToolbox(); } -exports.getInjectedToolbox = getInjectedToolbox; -function getBasicToolbox() { +export function getBasicToolbox() { const workspace = new Blockly.WorkspaceSvg(new Blockly.Options({})); const toolbox = new Blockly.Toolbox(workspace); toolbox.HtmlDiv = document.createElement('div'); toolbox.flyout_ = sinon.createStubInstance(Blockly.VerticalFlyout); return toolbox; } -exports.getBasicToolbox = getBasicToolbox; -function getCollapsibleItem(toolbox) { +export function getCollapsibleItem(toolbox) { const contents = toolbox.contents_; for (let i = 0; i < contents.length; i++) { const item = contents[i]; @@ -241,9 +234,8 @@ function getCollapsibleItem(toolbox) { } } } -exports.getCollapsibleItem = getCollapsibleItem; -function getNonCollapsibleItem(toolbox) { +export function getNonCollapsibleItem(toolbox) { const contents = toolbox.contents_; for (let i = 0; i < contents.length; i++) { const item = contents[i]; @@ -252,14 +244,11 @@ function getNonCollapsibleItem(toolbox) { } } } -exports.getNonCollapsibleItem = getNonCollapsibleItem; -function getChildItem(toolbox) { +export function getChildItem(toolbox) { return toolbox.getToolboxItemById('nestedCategory'); } -exports.getChildItem = getChildItem; -function getSeparator(toolbox) { +export function getSeparator(toolbox) { return toolbox.getToolboxItemById('separator'); } -exports.getSeparator = getSeparator; diff --git a/tests/mocha/test_helpers/user_input.js b/tests/mocha/test_helpers/user_input.js index 9482a7909..c625c6a11 100644 --- a/tests/mocha/test_helpers/user_input.js +++ b/tests/mocha/test_helpers/user_input.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.userInput'); +goog.declareModuleId('Blockly.test.helpers.userInput'); -const {KeyCodes} = goog.require('Blockly.utils.KeyCodes'); +import {KeyCodes} from '../../../build/src/core/utils/keycodes.js'; /** @@ -17,7 +17,7 @@ const {KeyCodes} = goog.require('Blockly.utils.KeyCodes'); * @param {Object=} properties Properties to pass into event * constructor. */ -function dispatchPointerEvent(target, type, properties) { +export function dispatchPointerEvent(target, type, properties) { const eventInitDict = { cancelable: true, bubbles: true, @@ -32,7 +32,6 @@ function dispatchPointerEvent(target, type, properties) { const event = new PointerEvent(type, eventInitDict); target.dispatchEvent(event); } -exports.dispatchPointerEvent = dispatchPointerEvent; /** * Creates a key down event used for testing. @@ -40,7 +39,7 @@ exports.dispatchPointerEvent = dispatchPointerEvent; * @param {!Array=} modifiers A list of modifiers. Use Blockly.utils.KeyCodes enum. * @return {!KeyboardEvent} The mocked keydown event. */ -function createKeyDownEvent(keyCode, modifiers) { +export function createKeyDownEvent(keyCode, modifiers) { const event = { keyCode: keyCode, }; @@ -52,7 +51,6 @@ function createKeyDownEvent(keyCode, modifiers) { } return new KeyboardEvent('keydown', event); } -exports.createKeyDownEvent = createKeyDownEvent; /** * Simulates mouse click by triggering relevant mouse events. @@ -60,9 +58,8 @@ exports.createKeyDownEvent = createKeyDownEvent; * @param {Object=} properties Properties to pass into event * constructor. */ -function simulateClick(target, properties) { +export function simulateClick(target, properties) { dispatchPointerEvent(target, 'pointerdown', properties); dispatchPointerEvent(target, 'pointerup', properties); dispatchPointerEvent(target, 'click', properties); } -exports.simulateClick = simulateClick; diff --git a/tests/mocha/test_helpers/variables.js b/tests/mocha/test_helpers/variables.js index f550e960b..e75047c06 100644 --- a/tests/mocha/test_helpers/variables.js +++ b/tests/mocha/test_helpers/variables.js @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.variables'); +goog.declareModuleId('Blockly.test.helpers.variables'); /** @@ -15,11 +15,10 @@ goog.module('Blockly.test.helpers.variables'); * @param {!string} type The expected type of the variable. * @param {!string} id The expected id of the variable. */ -function assertVariableValues(container, name, type, id) { +export function assertVariableValues(container, name, type, id) { const variable = container.getVariableById(id); chai.assert.isDefined(variable); chai.assert.equal(variable.name, name); chai.assert.equal(variable.type, type); chai.assert.equal(variable.getId(), id); } -exports.assertVariableValues = assertVariableValues; diff --git a/tests/mocha/test_helpers/warnings.js b/tests/mocha/test_helpers/warnings.js index 0457395cc..4d8658573 100644 --- a/tests/mocha/test_helpers/warnings.js +++ b/tests/mocha/test_helpers/warnings.js @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.warnings'); +goog.declareModuleId('Blockly.test.helpers.warnings'); /** @@ -13,7 +13,7 @@ goog.module('Blockly.test.helpers.warnings'); * @param {Function} innerFunc The function where warnings may called. * @return {Array} The warning messages (only the first arguments). */ -function captureWarnings(innerFunc) { +export function captureWarnings(innerFunc) { const msgs = []; const nativeConsoleWarn = console.warn; try { @@ -26,7 +26,6 @@ function captureWarnings(innerFunc) { } return msgs; } -exports.captureWarnings = captureWarnings; /** * Asserts that the given function logs the provided warning messages. @@ -34,7 +33,7 @@ exports.captureWarnings = captureWarnings; * @param {Array|!RegExp} messages A list of regex for the expected * messages (in the expected order). */ -function assertWarnings(innerFunc, messages) { +export function assertWarnings(innerFunc, messages) { if (!Array.isArray(messages)) { messages = [messages]; } @@ -44,25 +43,22 @@ function assertWarnings(innerFunc, messages) { chai.assert.match(warnings[i], message); }); } -exports.assertWarnings = assertWarnings; /** * Asserts that the given function logs no warning messages. * @param {function()} innerFunc The function to call. */ -function assertNoWarnings(innerFunc) { +export function assertNoWarnings(innerFunc) { assertWarnings(innerFunc, []); } -exports.assertNoWarnings = assertNoWarnings; /** * Stubs Blockly.utils.deprecation.warn call. * @return {!SinonStub} The created stub. */ -function createDeprecationWarningStub() { +export function createDeprecationWarningStub() { return sinon.stub(Blockly.utils.deprecation, 'warn'); } -exports.createDeprecationWarningStub = createDeprecationWarningStub; /** * Asserts whether the given deprecation warning stub or call was called with @@ -71,10 +67,9 @@ exports.createDeprecationWarningStub = createDeprecationWarningStub; * @param {string} functionName The function name to check that the given spy or * spy call was called with. */ -function assertDeprecationWarningCall(spyOrSpyCall, functionName) { +export function assertDeprecationWarningCall(spyOrSpyCall, functionName) { sinon.assert.calledWith(spyOrSpyCall, functionName); } -exports.assertDeprecationWarningCall = assertDeprecationWarningCall; /** * Asserts that there was a single deprecation warning call with the given @@ -83,8 +78,7 @@ exports.assertDeprecationWarningCall = assertDeprecationWarningCall; * @param {string} functionName The function name to check that the given spy * was called with. */ -function assertSingleDeprecationWarningCall(spy, functionName) { +export function assertSingleDeprecationWarningCall(spy, functionName) { sinon.assert.calledOnce(spy); assertDeprecationWarningCall(spy.getCall(0), functionName); } -exports.assertSingleDeprecationWarningCall = assertSingleDeprecationWarningCall; diff --git a/tests/mocha/test_helpers/workspace.js b/tests/mocha/test_helpers/workspace.js index 3ed1f628a..0500a29da 100644 --- a/tests/mocha/test_helpers/workspace.js +++ b/tests/mocha/test_helpers/workspace.js @@ -4,15 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.helpers.workspace'); +goog.declareModuleId('Blockly.test.helpers.workspace'); -const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); -const {assertWarnings} = goog.require('Blockly.test.helpers.warnings'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {assertVariableValues} from './variables.js'; +import {assertWarnings} from './warnings.js'; +import * as eventUtils from '../../../build/src/core/events/utils.js'; +import {workspaceTeardown} from './setup_teardown.js'; -function testAWorkspace() { +export function testAWorkspace() { setup(function() { Blockly.defineBlocksWithJsonArray([{ "type": "get_var_block", @@ -1528,4 +1528,3 @@ function testAWorkspace() { }); }); } -exports.testAWorkspace = testAWorkspace; diff --git a/tests/mocha/theme_test.js b/tests/mocha/theme_test.js index 1a57cb30f..0e4fa6faa 100644 --- a/tests/mocha/theme_test.js +++ b/tests/mocha/theme_test.js @@ -4,11 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.theme'); +goog.declareModuleId('Blockly.test.theme'); -const {assertEventFired} = goog.require('Blockly.test.helpers.events'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {assertEventFired} from './test_helpers/events.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('Theme', function() { diff --git a/tests/mocha/toolbox_test.js b/tests/mocha/toolbox_test.js index 65acef5b4..40007651c 100644 --- a/tests/mocha/toolbox_test.js +++ b/tests/mocha/toolbox_test.js @@ -4,11 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.toolbox'); +goog.declareModuleId('Blockly.test.toolbox'); -const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {getBasicToolbox, getCategoryJSON, getChildItem, getCollapsibleItem, getDeeplyNestedJSON, getInjectedToolbox, getNonCollapsibleItem, getSeparator, getSimpleJson, getXmlArray} = goog.require('Blockly.test.helpers.toolboxDefinitions'); +import {defineStackBlock} from './test_helpers/block_definitions.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {getBasicToolbox, getCategoryJSON, getChildItem, getCollapsibleItem, getDeeplyNestedJSON, getInjectedToolbox, getNonCollapsibleItem, getSeparator, getSimpleJson, getXmlArray} from './test_helpers/toolbox_definitions.js'; suite('Toolbox', function() { diff --git a/tests/mocha/tooltip_test.js b/tests/mocha/tooltip_test.js index 5483ea390..3d3755aa0 100644 --- a/tests/mocha/tooltip_test.js +++ b/tests/mocha/tooltip_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.tooltip'); +goog.declareModuleId('Blockly.test.tooltip'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; suite('Tooltip', function() { diff --git a/tests/mocha/trashcan_test.js b/tests/mocha/trashcan_test.js index c57d6cb6f..f52a9b55d 100644 --- a/tests/mocha/trashcan_test.js +++ b/tests/mocha/trashcan_test.js @@ -4,13 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.trashcan'); +goog.declareModuleId('Blockly.test.trashcan'); -const {assertEventFired, assertEventNotFired} = goog.require('Blockly.test.helpers.events'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {defineBasicBlockWithField, defineMutatorBlocks, defineRowBlock, defineStackBlock, defineStatementBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {simulateClick} = goog.require('Blockly.test.helpers.userInput'); +import {assertEventFired, assertEventNotFired} from './test_helpers/events.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {defineBasicBlockWithField, defineMutatorBlocks, defineRowBlock, defineStackBlock, defineStatementBlock} from './test_helpers/block_definitions.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {simulateClick} from './test_helpers/user_input.js'; suite("Trashcan", function() { diff --git a/tests/mocha/utils_test.js b/tests/mocha/utils_test.js index 02dcd078a..c7c38a86b 100644 --- a/tests/mocha/utils_test.js +++ b/tests/mocha/utils_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.utils'); +goog.declareModuleId('Blockly.test.utils'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Utils', function() { diff --git a/tests/mocha/variable_map_test.js b/tests/mocha/variable_map_test.js index 14bc0168e..c6a4701fc 100644 --- a/tests/mocha/variable_map_test.js +++ b/tests/mocha/variable_map_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.variableMap'); +goog.declareModuleId('Blockly.test.variableMap'); -const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); -const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {assertVariableValues} from './test_helpers/variables.js'; +import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Variable Map', function() { diff --git a/tests/mocha/variable_model_test.js b/tests/mocha/variable_model_test.js index 08a134642..ae9c894a6 100644 --- a/tests/mocha/variable_model_test.js +++ b/tests/mocha/variable_model_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.variableModel'); +goog.declareModuleId('Blockly.test.variableModel'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Variable Model', function() { diff --git a/tests/mocha/widget_div_test.js b/tests/mocha/widget_div_test.js index dade02878..864f4c09d 100644 --- a/tests/mocha/widget_div_test.js +++ b/tests/mocha/widget_div_test.js @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.widgetDiv'); +goog.declareModuleId('Blockly.test.widgetDiv'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('WidgetDiv', function() { diff --git a/tests/mocha/workspace_comment_test.js b/tests/mocha/workspace_comment_test.js index 233e42e39..e4ec13f58 100644 --- a/tests/mocha/workspace_comment_test.js +++ b/tests/mocha/workspace_comment_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.workspaceComment'); +goog.declareModuleId('Blockly.test.workspaceComment'); -goog.require('Blockly.WorkspaceComment'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); +import {WorkspaceComment} from '../../build/src/core/workspace_comment.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; suite('Workspace comment', function() { diff --git a/tests/mocha/workspace_svg_test.js b/tests/mocha/workspace_svg_test.js index d30374c10..49cbad0e1 100644 --- a/tests/mocha/workspace_svg_test.js +++ b/tests/mocha/workspace_svg_test.js @@ -4,14 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.workspaceSvg'); +goog.declareModuleId('Blockly.test.workspaceSvg'); -const {assertEventFired, assertEventNotFired, createFireChangeListenerSpy} = goog.require('Blockly.test.helpers.events'); -const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); -const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {testAWorkspace} = goog.require('Blockly.test.helpers.workspace'); +import {assertEventFired, assertEventNotFired, createFireChangeListenerSpy} from './test_helpers/events.js'; +import {assertVariableValues} from './test_helpers/variables.js'; +import {defineStackBlock} from './test_helpers/block_definitions.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {testAWorkspace} from './test_helpers/workspace.js'; suite('WorkspaceSvg', function() { diff --git a/tests/mocha/workspace_test.js b/tests/mocha/workspace_test.js index 8153518b0..ad90ebad8 100644 --- a/tests/mocha/workspace_test.js +++ b/tests/mocha/workspace_test.js @@ -4,11 +4,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.workspace'); +goog.declareModuleId('Blockly.test.workspace'); -const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); -const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {testAWorkspace} = goog.require('Blockly.test.helpers.workspace'); +import {assertVariableValues} from './test_helpers/variables.js'; +import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {testAWorkspace} from './test_helpers/workspace.js'; suite('Workspace', function() { diff --git a/tests/mocha/xml_test.js b/tests/mocha/xml_test.js index 78ddeeeef..1306918e6 100644 --- a/tests/mocha/xml_test.js +++ b/tests/mocha/xml_test.js @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.xml'); +goog.declareModuleId('Blockly.test.xml'); -const {addBlockTypeToCleanup, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); +import {addBlockTypeToCleanup, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js'; +import {assertVariableValues} from './test_helpers/variables.js'; suite('XML', function() { diff --git a/tests/mocha/zoom_controls_test.js b/tests/mocha/zoom_controls_test.js index 573e8b8ff..530418dae 100644 --- a/tests/mocha/zoom_controls_test.js +++ b/tests/mocha/zoom_controls_test.js @@ -4,12 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -goog.module('Blockly.test.zoomControls'); +goog.declareModuleId('Blockly.test.zoomControls'); -const {assertEventFired, assertEventNotFired} = goog.require('Blockly.test.helpers.events'); -const eventUtils = goog.require('Blockly.Events.utils'); -const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); -const {simulateClick} = goog.require('Blockly.test.helpers.userInput'); +import {assertEventFired, assertEventNotFired} from './test_helpers/events.js'; +import * as eventUtils from '../../build/src/core/events/utils.js'; +import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js'; +import {simulateClick} from './test_helpers/user_input.js'; suite("Zoom Controls", function() {