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
This commit is contained in:
Beka Westberg
2022-08-10 21:54:02 +00:00
committed by GitHub
parent f032151cd9
commit 96758fedd4
74 changed files with 324 additions and 359 deletions

View File

@@ -11,7 +11,11 @@
"no-unused-vars": ["off"], "no-unused-vars": ["off"],
// Allow uncommented helper functions in tests. // Allow uncommented helper functions in tests.
"require-jsdoc": ["off"], "require-jsdoc": ["off"],
"prefer-rest-params": ["off"] "prefer-rest-params": ["off"],
"no-invalid-this": ["off"]
}, },
"extends": "../../.eslintrc.json" "extends": "../../.eslintrc.json",
"parserOptions": {
"sourceType": "module"
}
} }

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.astNode'); goog.declareModuleId('Blockly.test.astNode');
const {ASTNode} = goog.require('Blockly.ASTNode'); import {ASTNode} from '../../build/src/core/keyboard_nav/ast_node.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
suite('ASTNode', function() { suite('ASTNode', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
const {defineMutatorBlocks} = goog.require('Blockly.test.helpers.blockDefinitions'); import {defineMutatorBlocks} from './test_helpers/block_definitions.js';
suite('Block Change Event', function() { suite('Block Change Event', function() {

View File

@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.blockCreateEvent'); goog.declareModuleId('Blockly.test.blockCreateEvent');
const {assertEventFired} = goog.require('Blockly.test.helpers.events'); import {assertEventFired} from './test_helpers/events.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Block Create Event', function() { suite('Block Create Event', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Block JSON initialization', function() {

View File

@@ -4,14 +4,13 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.blocks'); goog.declareModuleId('Blockly.test.blocks');
const {Blocks} = goog.require('Blockly.blocks'); import {ConnectionType} from '../../build/src/core/connection_type.js';
const {ConnectionType} = goog.require('Blockly.ConnectionType'); import {createDeprecationWarningStub} from './test_helpers/warnings.js';
const {createDeprecationWarningStub} = goog.require('Blockly.test.helpers.warnings'); import {createRenderedBlock} from './test_helpers/block_definitions.js';
const {createRenderedBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import * as eventUtils from '../../build/src/core/events/utils.js';
const eventUtils = goog.require('Blockly.Events.utils'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown');
suite('Blocks', function() { suite('Blocks', function() {
@@ -1990,7 +1989,7 @@ suite('Blocks', function() {
// so we assert init was called to be safe. // so we assert init was called to be safe.
let initCalled = false; let initCalled = false;
let recordUndoDuringInit; let recordUndoDuringInit;
Blocks['init_test_block'].init = function() { Blockly.Blocks['init_test_block'].init = function() {
initCalled = true; initCalled = true;
recordUndoDuringInit = eventUtils.getRecordUndo(); recordUndoDuringInit = eventUtils.getRecordUndo();
throw new Error(); throw new Error();

View File

@@ -4,12 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.lists'); goog.declareModuleId('Blockly.test.lists');
const {runSerializationTestSuite} = goog.require('Blockly.test.helpers.serialization'); import {runSerializationTestSuite} from '../test_helpers/serialization.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from '../test_helpers/setup_teardown.js';
const {ConnectionType} = goog.require('Blockly.ConnectionType'); import {ConnectionType} from '../../build/src/core/connection_type.js';
const {defineStatementBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {defineStatementBlock} from '../test_helpers/block_definitions.js';
suite('Lists', function() { suite('Lists', function() {

View File

@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.logicTernary'); goog.declareModuleId('Blockly.test.logicTernary');
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
const {runSerializationTestSuite} = goog.require('Blockly.test.helpers.serialization'); import {runSerializationTestSuite} from '../test_helpers/serialization.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from '../test_helpers/setup_teardown.js';
suite('Logic ternary', function() { suite('Logic ternary', function() {

View File

@@ -4,13 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.procedures'); goog.declareModuleId('Blockly.test.procedures');
goog.require('Blockly'); import * as Blockly from '../../build/src/core/blockly.js';
goog.require('Blockly.Msg'); import {assertCallBlockStructure, assertDefBlockStructure, createProcDefBlock, createProcCallBlock} from '../test_helpers/procedures.js';
const {assertCallBlockStructure, assertDefBlockStructure, createProcDefBlock, createProcCallBlock} = goog.require('Blockly.test.helpers.procedures'); import {runSerializationTestSuite} from '../test_helpers/serialization.js';
const {runSerializationTestSuite} = goog.require('Blockly.test.helpers.serialization'); import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from '../test_helpers/setup_teardown.js';
const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown');
suite('Procedures', function() { suite('Procedures', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Variables', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
const {simulateClick} = goog.require('Blockly.test.helpers.userInput'); import {simulateClick} from './test_helpers/user_input.js';
suite('Comment Deserialization', function() { suite('Comment Deserialization', function() {

View File

@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.comments'); goog.declareModuleId('Blockly.test.comments');
const {assertEventFired} = goog.require('Blockly.test.helpers.events'); import {assertEventFired} from './test_helpers/events.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Comments', function() { suite('Comments', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.connectionChecker'); goog.declareModuleId('Blockly.test.connectionChecker');
const {ConnectionType} = goog.require('Blockly.ConnectionType'); import {ConnectionType} from '../../build/src/core/connection_type.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Connection checker', function() { suite('Connection checker', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.connectionDb'); goog.declareModuleId('Blockly.test.connectionDb');
const {ConnectionType} = goog.require('Blockly.ConnectionType'); import {ConnectionType} from '../../build/src/core/connection_type.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Connection Database', function() { suite('Connection Database', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
const {defineRowBlock, defineStatementBlock, defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {defineRowBlock, defineStatementBlock, defineStackBlock} from './test_helpers/block_definitions.js';
suite('Connection', function() { suite('Connection', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Context Menu Items', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
const {ASTNode} = goog.require('Blockly.ASTNode'); import {ASTNode} from '../../build/src/core/keyboard_nav/ast_node.js';
suite('Cursor', function() { suite('Cursor', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('DropDownDiv', function() {

View File

@@ -4,14 +4,15 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.event'); goog.declareModuleId('Blockly.test.event');
const {ASTNode} = goog.require('Blockly.ASTNode'); import * as Blockly from '../../build/src/core/blockly.js';
const {assertEventEquals, assertNthCallEventArgEquals, createFireChangeListenerSpy} = goog.require('Blockly.test.helpers.events'); import {ASTNode} from '../../build/src/core/keyboard_nav/ast_node.js';
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); import {assertEventEquals, assertNthCallEventArgEquals, createFireChangeListenerSpy} from './test_helpers/events.js';
const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {assertVariableValues} from './test_helpers/variables.js';
const eventUtils = goog.require('Blockly.Events.utils'); import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
goog.require('Blockly.WorkspaceComment'); import * as eventUtils from '../../build/src/core/events/utils.js';
import {WorkspaceComment} from '../../build/src/core/workspace_comment.js';
suite('Events', function() { suite('Events', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Extensions', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js';
import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
suite('Angle Fields', function() { suite('Angle Fields', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
import {defineRowBlock} from './test_helpers/block_definitions.js';
suite('Checkbox Fields', function() { suite('Checkbox Fields', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js';
import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
suite('Colour Fields', function() { suite('Colour Fields', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js';
import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
suite('Dropdown Fields', function() { suite('Dropdown Fields', function() {

View File

@@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Image Fields', function() { suite('Image Fields', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js';
suite('Label Serializable Fields', function() { suite('Label Serializable Fields', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {createTestBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
import {createTestBlock} from './test_helpers/block_definitions.js';
suite('Label Fields', function() { suite('Label Fields', function() {

View File

@@ -4,12 +4,18 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js';
const {runCodeGenerationTestSuites} = goog.require('Blockly.test.helpers.codeGeneration'); 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() { suite('Multiline Input Fields', function() {

View File

@@ -4,12 +4,13 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {defineRowBlock} from './test_helpers/block_definitions.js';
const {runTestCases} = goog.require('Blockly.test.helpers.common'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
import {runTestCases} from './test_helpers/common.js';
suite('Number Fields', function() { suite('Number Fields', function() {

View File

@@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.fieldRegistry'); goog.declareModuleId('Blockly.test.fieldRegistry');
const {createDeprecationWarningStub} = goog.require('Blockly.test.helpers.warnings'); import * as Blockly from '../../build/src/core/blockly.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {createDeprecationWarningStub} from './test_helpers/warnings.js';
import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Field Registry', function() { suite('Field Registry', function() {

View File

@@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {createDeprecationWarningStub} = goog.require('Blockly.test.helpers.warnings'); import {addBlockTypeToCleanup, addMessageToCleanup, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
import {createDeprecationWarningStub} from './test_helpers/warnings.js';
suite('Abstract Fields', function() { suite('Abstract Fields', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js';
import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
suite('Text Input Fields', function() { suite('Text Input Fields', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {assertFieldValue, runConstructorSuiteTests, runFromJsonSuiteTests, runSetValueTests} from './test_helpers/fields.js';
const {createTestBlock, defineRowBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
import {createTestBlock, defineRowBlock} from './test_helpers/block_definitions.js';
suite('Variable Fields', function() { suite('Variable Fields', function() {

View File

@@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
const {getBasicToolbox, getChildItem, getCollapsibleItem, getDeeplyNestedJSON, getInjectedToolbox, getNonCollapsibleItem, getProperSimpleJson, getSeparator, getSimpleJson, getXmlArray} = goog.require('Blockly.test.helpers.toolboxDefinitions'); 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() { suite('Flyout', function() {

View File

@@ -4,14 +4,15 @@
* SPDX-License-Identifier: Apache-2.0 * 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 {dartGenerator} = goog.require('Blockly.Dart');
const {javaScriptGenerator} = goog.require('Blockly.JavaScript'); const {javascriptGenerator} = goog.require('Blockly.JavaScript');
const {luaGenerator} = goog.require('Blockly.Lua'); const {luaGenerator} = goog.require('Blockly.Lua');
const {phpGenerator} = goog.require('Blockly.PHP'); const {phpGenerator} = goog.require('Blockly.PHP');
const {pythonGenerator} = goog.require('Blockly.Python'); 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() { suite('Generator', function() {

View File

@@ -4,13 +4,13 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {assertEventFired, assertEventNotFired} from './test_helpers/events.js';
const {defineBasicBlockWithField} = goog.require('Blockly.test.helpers.blockDefinitions'); import {defineBasicBlockWithField} from './test_helpers/block_definitions.js';
const {dispatchPointerEvent} = goog.require('Blockly.test.helpers.userInput'); import {dispatchPointerEvent} from './test_helpers/user_input.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Gesture', function() { suite('Gesture', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Inputs', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('InsertionMarkers', function() {

View File

@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
const {assertEventFired} = goog.require('Blockly.test.helpers.events'); import {assertEventFired} from './test_helpers/events.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
suite('JSO Deserialization', function() { suite('JSO Deserialization', function() {

View File

@@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {defineRowBlock, defineStackBlock, defineStatementBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); 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() { suite('JSO Serialization', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {addMessageToCleanup, sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
const {assertNoWarnings, assertWarnings} = goog.require('Blockly.test.helpers.warnings'); import {assertNoWarnings, assertWarnings} from './test_helpers/warnings.js';
suite('JSON Block Definitions', function() { suite('JSON Block Definitions', function() {

View File

@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.keydown'); goog.declareModuleId('Blockly.test.keydown');
const {createKeyDownEvent} = goog.require('Blockly.test.helpers.userInput'); import * as Blockly from '../../build/src/core/blockly.js';
const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {createKeyDownEvent} from './test_helpers/user_input.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {defineStackBlock} from './test_helpers/block_definitions.js';
import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Key Down', function() { suite('Key Down', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Metrics', function() {

View File

@@ -5,10 +5,10 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
const {createRenderedBlock, defineMutatorBlocks} = goog.require('Blockly.test.helpers.blockDefinitions'); import {createRenderedBlock, defineMutatorBlocks} from './test_helpers/block_definitions.js';
suite('Mutator', function() { suite('Mutator', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Names', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.registry'); goog.declareModuleId('Blockly.test.registry');
const {assertWarnings} = goog.require('Blockly.test.helpers.warnings'); import {assertWarnings} from './test_helpers/warnings.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Registry', function() { suite('Registry', function() {

View File

@@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import * as Blockly from '../../build/src/core/blockly.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); 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. // TODO: Move this into samples as part of the dev-tools package.

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.shortcutRegistry'); goog.declareModuleId('Blockly.test.shortcutRegistry');
const {createKeyDownEvent} = goog.require('Blockly.test.helpers.userInput'); import {createKeyDownEvent} from './test_helpers/user_input.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Keyboard Shortcut Registry Test', function() { suite('Keyboard Shortcut Registry Test', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * 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([{ Blockly.defineBlocksWithJsonArray([{
"type": name, "type": name,
"message0": "", "message0": "",
@@ -15,9 +15,8 @@ function defineStackBlock(name = 'stack_block') {
"nextStatement": null, "nextStatement": null,
}]); }]);
} }
exports.defineStackBlock = defineStackBlock;
function defineRowBlock(name = 'row_block') { export function defineRowBlock(name = 'row_block') {
Blockly.defineBlocksWithJsonArray([{ Blockly.defineBlocksWithJsonArray([{
"type": name, "type": name,
"message0": "%1", "message0": "%1",
@@ -30,9 +29,8 @@ function defineRowBlock(name = 'row_block') {
"output": null, "output": null,
}]); }]);
} }
exports.defineRowBlock = defineRowBlock;
function defineStatementBlock(name = 'statement_block') { export function defineStatementBlock(name = 'statement_block') {
Blockly.defineBlocksWithJsonArray([{ Blockly.defineBlocksWithJsonArray([{
"type": name, "type": name,
"message0": "%1", "message0": "%1",
@@ -49,9 +47,8 @@ function defineStatementBlock(name = 'statement_block') {
"helpUrl": "", "helpUrl": "",
}]); }]);
} }
exports.defineStatementBlock = defineStatementBlock;
function defineBasicBlockWithField(name = 'test_field_block') { export function defineBasicBlockWithField(name = 'test_field_block') {
Blockly.defineBlocksWithJsonArray([{ Blockly.defineBlocksWithJsonArray([{
"type": name, "type": name,
"message0": "%1", "message0": "%1",
@@ -64,9 +61,8 @@ function defineBasicBlockWithField(name = 'test_field_block') {
"output": null, "output": null,
}]); }]);
} }
exports.defineBasicBlockWithField = defineBasicBlockWithField;
function defineMutatorBlocks() { export function defineMutatorBlocks() {
Blockly.defineBlocksWithJsonArray([ Blockly.defineBlocksWithJsonArray([
{ {
'type': 'xml_block', 'type': 'xml_block',
@@ -158,9 +154,8 @@ function defineMutatorBlocks() {
}; };
Blockly.Extensions.registerMutator('jso_mutator', jsoMutator); Blockly.Extensions.registerMutator('jso_mutator', jsoMutator);
} }
exports.defineMutatorBlocks = defineMutatorBlocks;
function createTestBlock() { export function createTestBlock() {
return { return {
'id': 'test', 'id': 'test',
'rendered': false, 'rendered': false,
@@ -174,12 +169,10 @@ function createTestBlock() {
'updateVarName': Blockly.Block.prototype.updateVarName, 'updateVarName': Blockly.Block.prototype.updateVarName,
}; };
} }
exports.createTestBlock = createTestBlock;
function createRenderedBlock(workspaceSvg, type) { export function createRenderedBlock(workspaceSvg, type) {
const block = workspaceSvg.newBlock(type); const block = workspaceSvg.newBlock(type);
block.initSvg(); block.initSvg();
block.render(); block.render();
return block; return block;
} }
exports.createRenderedBlock = createRenderedBlock;

View File

@@ -5,9 +5,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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} * @implements {TestCase}
* @record * @record
*/ */
class CodeGenerationTestCase { export class CodeGenerationTestCase {
/** /**
* Class for a code generation test case. * Class for a code generation test case.
*/ */
@@ -43,14 +43,13 @@ class CodeGenerationTestCase {
*/ */
createBlock(workspace) {} createBlock(workspace) {}
} }
exports.CodeGenerationTestCase = CodeGenerationTestCase;
/** /**
* Code generation test suite. * Code generation test suite.
* @extends {TestSuite<CodeGenerationTestCase, CodeGenerationTestSuite>} * @extends {TestSuite<CodeGenerationTestCase, CodeGenerationTestSuite>}
* @record * @record
*/ */
class CodeGenerationTestSuite { export class CodeGenerationTestSuite {
/** /**
* Class for a code generation test suite. * Class for a code generation test suite.
*/ */
@@ -61,7 +60,6 @@ class CodeGenerationTestSuite {
this.generator; this.generator;
} }
} }
exports.CodeGenerationTestSuite = CodeGenerationTestSuite;
/** /**
* Returns mocha test callback for code generation based on provided * Returns mocha test callback for code generation based on provided
@@ -102,7 +100,7 @@ const createCodeGenerationTestFn_ = (generator) => {
* Runs blockToCode test suites. * Runs blockToCode test suites.
* @param {!Array<!CodeGenerationTestSuite>} testSuites The test suites to run. * @param {!Array<!CodeGenerationTestSuite>} testSuites The test suites to run.
*/ */
const runCodeGenerationTestSuites = (testSuites) => { export const runCodeGenerationTestSuites = (testSuites) => {
/** /**
* Creates function used to generate mocha test callback. * Creates function used to generate mocha test callback.
* @param {!CodeGenerationTestSuite} suiteInfo The test suite information. * @param {!CodeGenerationTestSuite} suiteInfo The test suite information.
@@ -115,4 +113,3 @@ const runCodeGenerationTestSuites = (testSuites) => {
runTestSuites(testSuites, createTestFn); runTestSuites(testSuites, createTestFn);
}; };
exports.runCodeGenerationTestSuites = runCodeGenerationTestSuites;

View File

@@ -4,13 +4,13 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.helpers.common'); goog.declareModuleId('Blockly.test.helpers.common');
/** /**
* Test case configuration. * Test case configuration.
* @record * @record
*/ */
class TestCase { export class TestCase {
/** /**
* Class for a test case configuration. * Class for a test case configuration.
*/ */
@@ -31,7 +31,6 @@ class TestCase {
this.only; this.only;
} }
} }
exports.TestCase = TestCase;
/** /**
* Test suite configuration. * Test suite configuration.
@@ -39,7 +38,7 @@ exports.TestCase = TestCase;
* @template {TestCase} T * @template {TestCase} T
* @template {TestSuite} U * @template {TestSuite} U
*/ */
class TestSuite { export class TestSuite {
/** /**
* Class for a test suite configuration. * Class for a test suite configuration.
*/ */
@@ -68,7 +67,6 @@ class TestSuite {
this.only; this.only;
} }
} }
exports.TestSuite = TestSuite;
/** /**
* Runs provided test cases. * Runs provided test cases.
@@ -77,14 +75,13 @@ exports.TestSuite = TestSuite;
* @param {function(T):Function} createTestCallback Creates test * @param {function(T):Function} createTestCallback Creates test
* callback using given test case. * callback using given test case.
*/ */
function runTestCases(testCases, createTestCallback) { export function runTestCases(testCases, createTestCallback) {
testCases.forEach((testCase) => { testCases.forEach((testCase) => {
let testCall = (testCase.skip ? test.skip : test); let testCall = (testCase.skip ? test.skip : test);
testCall = (testCase.only ? test.only : testCall); testCall = (testCase.only ? test.only : testCall);
testCall(testCase.title, createTestCallback(testCase)); testCall(testCase.title, createTestCallback(testCase));
}); });
} }
exports.runTestCases = runTestCases;
/** /**
* Runs provided test suite. * Runs provided test suite.
@@ -95,7 +92,7 @@ exports.runTestCases = runTestCases;
* } createTestCaseCallback Creates test case callback using given test * } createTestCaseCallback Creates test case callback using given test
* suite. * suite.
*/ */
function runTestSuites(testSuites, createTestCaseCallback) { export function runTestSuites(testSuites, createTestCaseCallback) {
testSuites.forEach((testSuite) => { testSuites.forEach((testSuite) => {
let suiteCall = (testSuite.skip ? suite.skip : suite); let suiteCall = (testSuite.skip ? suite.skip : suite);
suiteCall = (testSuite.only ? suite.only : suiteCall); suiteCall = (testSuite.only ? suite.only : suiteCall);
@@ -109,4 +106,3 @@ function runTestSuites(testSuites, createTestCaseCallback) {
}); });
}); });
} }
exports.runTestSuites = runTestSuites;

View File

@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * 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. * calls on.
* @return {!SinonSpy} The created spy. * @return {!SinonSpy} The created spy.
*/ */
function createFireChangeListenerSpy(workspace) { export function createFireChangeListenerSpy(workspace) {
return sinon.spy(workspace, 'fireChangeListener'); return sinon.spy(workspace, 'fireChangeListener');
} }
exports.createFireChangeListenerSpy = createFireChangeListenerSpy;
/** /**
* Asserts whether the given xml property has the expected property. * 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 {boolean=} [isUiEvent=false] Whether the event is a UI event.
* @param {string=} message Optional message to prepend assert messages. * @param {string=} message Optional message to prepend assert messages.
*/ */
function assertEventEquals(event, expectedType, export function assertEventEquals(event, expectedType,
expectedWorkspaceId, expectedBlockId, expectedProperties, isUiEvent = false, message) { expectedWorkspaceId, expectedBlockId, expectedProperties, isUiEvent = false, message) {
let prependMessage = message ? message + ' ' : ''; let prependMessage = message ? message + ' ' : '';
prependMessage += 'Event fired '; prependMessage += 'Event fired ';
@@ -107,7 +106,6 @@ function assertEventEquals(event, expectedType,
chai.assert.isFalse(event.isUiEvent); chai.assert.isFalse(event.isUiEvent);
} }
} }
exports.assertEventEquals = assertEventEquals;
/** /**
* Asserts that an event with the given values was fired. * 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} expectedWorkspaceId Expected workspace id of event fired.
* @param {?string=} expectedBlockId Expected block 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) { expectedWorkspaceId, expectedBlockId) {
expectedProperties = Object.assign({ expectedProperties = Object.assign({
workspaceId: expectedWorkspaceId, workspaceId: expectedWorkspaceId,
@@ -129,7 +127,6 @@ function assertEventFired(spy, instanceType, expectedProperties,
sinon.match.instanceOf(instanceType).and(sinon.match(expectedProperties)); sinon.match.instanceOf(instanceType).and(sinon.match(expectedProperties));
sinon.assert.calledWith(spy, expectedEvent); sinon.assert.calledWith(spy, expectedEvent);
} }
exports.assertEventFired = assertEventFired;
/** /**
* Asserts that an event with the given values was not fired. * 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=} expectedWorkspaceId Expected workspace id of event fired.
* @param {?string=} expectedBlockId Expected block 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) { expectedWorkspaceId, expectedBlockId) {
expectedProperties.type = instanceType.prototype.type; expectedProperties.type = instanceType.prototype.type;
if (expectedWorkspaceId !== undefined) { if (expectedWorkspaceId !== undefined) {
@@ -154,7 +151,6 @@ function assertEventNotFired(spy, instanceType, expectedProperties,
sinon.match.instanceOf(instanceType).and(sinon.match(expectedProperties)); sinon.match.instanceOf(instanceType).and(sinon.match(expectedProperties));
sinon.assert.neverCalledWith(spy, expectedEvent); sinon.assert.neverCalledWith(spy, expectedEvent);
} }
exports.assertEventNotFired = assertEventNotFired;
/** /**
* Filters out xml properties from given object based on key. * 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} expectedWorkspaceId Expected workspace id of event fired.
* @param {?string=} expectedBlockId Expected block 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) { expectedWorkspaceId, expectedBlockId) {
const nthCall = spy.getCall(n); const nthCall = spy.getCall(n);
const splitProperties = splitByXmlProperties_(expectedProperties); const splitProperties = splitByXmlProperties_(expectedProperties);
@@ -201,4 +197,3 @@ function assertNthCallEventArgEquals(spy, n, instanceType, expectedProperties,
const eventArg = nthCall.firstArg; const eventArg = nthCall.firstArg;
assertXmlProperties_(eventArg, xmlProperties); assertXmlProperties_(eventArg, xmlProperties);
} }
exports.assertNthCallEventArgEquals = assertNthCallEventArgEquals;

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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} * @implements {TestCase}
* @record * @record
*/ */
class FieldValueTestCase { export class FieldValueTestCase {
/** /**
* Class for a a field value test case. * Class for a a field value test case.
*/ */
@@ -39,14 +39,13 @@ class FieldValueTestCase {
this.errMsgMatcher; this.errMsgMatcher;
} }
} }
exports.FieldValueTestCase = FieldValueTestCase;
/** /**
* Field creation test case. * Field creation test case.
* @extends {FieldValueTestCase} * @extends {FieldValueTestCase}
* @record * @record
*/ */
class FieldCreationTestCase { export class FieldCreationTestCase {
/** /**
* Class for a field creation test case. * Class for a field creation test case.
*/ */
@@ -61,7 +60,6 @@ class FieldCreationTestCase {
this.json; this.json;
} }
} }
exports.FieldCreationTestCase = FieldCreationTestCase;
/** /**
* Assert a field's value is the same as the expected value. * 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 {*} expectedValue The expected value.
* @param {string=} expectedText The expected text. * @param {string=} expectedText The expected text.
*/ */
function assertFieldValue(field, expectedValue, expectedText = undefined) { export function assertFieldValue(field, expectedValue, expectedText = undefined) {
const actualValue = field.getValue(); const actualValue = field.getValue();
const actualText = field.getText(); const actualText = field.getText();
if (expectedText === undefined) { if (expectedText === undefined) {
@@ -78,7 +76,6 @@ function assertFieldValue(field, expectedValue, expectedText = undefined) {
chai.assert.equal(actualValue, expectedValue, 'Value'); chai.assert.equal(actualValue, expectedValue, 'Value');
chai.assert.equal(actualText, expectedText, 'Text'); chai.assert.equal(actualText, expectedText, 'Text');
} }
exports.assertFieldValue = assertFieldValue;
/** /**
* Runs provided creation test cases. * Runs provided creation test cases.
@@ -145,7 +142,7 @@ function runCreationTestsAssertThrows_(testCases, creation) {
* @param {function(!FieldCreationTestCase=)=} customCreateWithJs Custom * @param {function(!FieldCreationTestCase=)=} customCreateWithJs Custom
* creation function to use in tests. * creation function to use in tests.
*/ */
function runConstructorSuiteTests(TestedField, validValueTestCases, export function runConstructorSuiteTests(TestedField, validValueTestCases,
invalidValueTestCases, validRunAssertField, assertFieldDefault, invalidValueTestCases, validRunAssertField, assertFieldDefault,
customCreateWithJs) { customCreateWithJs) {
suite('Constructor', function() { suite('Constructor', function() {
@@ -182,7 +179,6 @@ function runConstructorSuiteTests(TestedField, validValueTestCases,
runCreationTests_(validValueTestCases, validRunAssertField, createWithJs); runCreationTests_(validValueTestCases, validRunAssertField, createWithJs);
}); });
} }
exports.runConstructorSuiteTests = runConstructorSuiteTests;
/** /**
* Runs suite of tests for fromJson creation of specified field. * Runs suite of tests for fromJson creation of specified field.
@@ -200,7 +196,7 @@ exports.runConstructorSuiteTests = runConstructorSuiteTests;
* @param {function(!FieldCreationTestCase=)=} customCreateWithJson Custom * @param {function(!FieldCreationTestCase=)=} customCreateWithJson Custom
* creation function to use in tests. * creation function to use in tests.
*/ */
function runFromJsonSuiteTests(TestedField, validValueTestCases, export function runFromJsonSuiteTests(TestedField, validValueTestCases,
invalidValueTestCases, validRunAssertField, assertFieldDefault, invalidValueTestCases, validRunAssertField, assertFieldDefault,
customCreateWithJson) { customCreateWithJson) {
suite('fromJson', function() { suite('fromJson', function() {
@@ -237,7 +233,6 @@ function runFromJsonSuiteTests(TestedField, validValueTestCases,
runCreationTests_(validValueTestCases, validRunAssertField, createWithJson); runCreationTests_(validValueTestCases, validRunAssertField, createWithJson);
}); });
} }
exports.runFromJsonSuiteTests = runFromJsonSuiteTests;
/** /**
* Runs tests for setValue calls. * Runs tests for setValue calls.
@@ -250,7 +245,7 @@ exports.runFromJsonSuiteTests = runFromJsonSuiteTests;
* @param {string=} invalidRunExpectedText Expected text for field after invalid * @param {string=} invalidRunExpectedText Expected text for field after invalid
* call to setValue. * call to setValue.
*/ */
function runSetValueTests(validValueTestCases, invalidValueTestCases, export function runSetValueTests(validValueTestCases, invalidValueTestCases,
invalidRunExpectedValue, invalidRunExpectedText) { invalidRunExpectedValue, invalidRunExpectedText) {
/** /**
* Creates test callback for invalid setValue test. * Creates test callback for invalid setValue test.
@@ -279,4 +274,3 @@ function runSetValueTests(validValueTestCases, invalidValueTestCases,
runTestCases(invalidValueTestCases, createInvalidSetValueTestCallback); runTestCases(invalidValueTestCases, createInvalidSetValueTestCallback);
runTestCases(validValueTestCases, createValidSetValueTestCallback); runTestCases(validValueTestCases, createValidSetValueTestCallback);
} }
exports.runSetValueTests = runSetValueTests;

View File

@@ -3,9 +3,9 @@
* Copyright 2020 Google LLC * Copyright 2020 Google LLC
* SPDX-License-Identifier: Apache-2.0 * 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 * @param {boolean=} hasStatements If we expect the procedure def to have a
* statement input or not. * statement input or not.
*/ */
function assertDefBlockStructure(defBlock, hasReturn = false, export function assertDefBlockStructure(defBlock, hasReturn = false,
args = [], varIds = [], hasStatements = true) { args = [], varIds = [], hasStatements = true) {
if (hasStatements) { if (hasStatements) {
chai.assert.isNotNull(defBlock.getInput('STACK'), chai.assert.isNotNull(defBlock.getInput('STACK'),
@@ -82,7 +82,6 @@ function assertDefBlockStructure(defBlock, hasReturn = false,
chai.assert.sameOrderedMembers(defBlock.getVars(), args); chai.assert.sameOrderedMembers(defBlock.getVars(), args);
assertBlockVarModels(defBlock, varIds); assertBlockVarModels(defBlock, varIds);
} }
exports.assertDefBlockStructure = assertDefBlockStructure;
/** /**
* Asserts that the procedure call block has the expected inputs and * Asserts that the procedure call block has the expected inputs and
@@ -92,7 +91,7 @@ exports.assertDefBlockStructure = assertDefBlockStructure;
* @param {Array<string>=} varIds An array of variable ids. * @param {Array<string>=} varIds An array of variable ids.
* @param {string=} name The name we expect the caller to have. * @param {string=} name The name we expect the caller to have.
*/ */
function assertCallBlockStructure( export function assertCallBlockStructure(
callBlock, args = [], varIds = [], name = undefined) { callBlock, args = [], varIds = [], name = undefined) {
if (args.length) { if (args.length) {
chai.assert.include(callBlock.toString(), 'with'); chai.assert.include(callBlock.toString(), 'with');
@@ -106,7 +105,6 @@ function assertCallBlockStructure(
chai.assert(callBlock.getFieldValue('NAME'), name); chai.assert(callBlock.getFieldValue('NAME'), name);
} }
} }
exports.assertCallBlockStructure = assertCallBlockStructure;
/** /**
* Creates procedure definition block using domToBlock call. * Creates procedure definition block using domToBlock call.
@@ -116,7 +114,7 @@ exports.assertCallBlockStructure = assertCallBlockStructure;
* @param {Array<string>=} args An array of argument names. * @param {Array<string>=} args An array of argument names.
* @return {Blockly.Block} The created block. * @return {Blockly.Block} The created block.
*/ */
function createProcDefBlock( export function createProcDefBlock(
workspace, hasReturn = false, args = []) { workspace, hasReturn = false, args = []) {
const type = hasReturn ? const type = hasReturn ?
'procedures_defreturn' : 'procedures_defnoreturn'; 'procedures_defreturn' : 'procedures_defnoreturn';
@@ -130,7 +128,6 @@ function createProcDefBlock(
'</block>'; '</block>';
return Blockly.Xml.domToBlock(Blockly.Xml.textToDom(xml), workspace); return Blockly.Xml.domToBlock(Blockly.Xml.textToDom(xml), workspace);
} }
exports.createProcDefBlock = createProcDefBlock;
/** /**
* Creates procedure call block using domToBlock call. * Creates procedure call block using domToBlock call.
@@ -139,7 +136,7 @@ exports.createProcDefBlock = createProcDefBlock;
* has return. * has return.
* @return {Blockly.Block} The created block. * @return {Blockly.Block} The created block.
*/ */
function createProcCallBlock( export function createProcCallBlock(
workspace, hasReturn = false) { workspace, hasReturn = false) {
const type = hasReturn ? const type = hasReturn ?
'procedures_callreturn' : 'procedures_callnoreturn'; 'procedures_callreturn' : 'procedures_callnoreturn';
@@ -149,4 +146,3 @@ function createProcCallBlock(
'</block>' '</block>'
), workspace); ), workspace);
} }
exports.createProcCallBlock = createProcCallBlock;

View File

@@ -4,16 +4,16 @@
* SPDX-License-Identifier: Apache-2.0 * 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. * Serialization test case.
* @implements {TestCase} * @implements {TestCase}
* @record * @record
*/ */
class SerializationTestCase { export class SerializationTestCase {
/** /**
* Class for a block serialization test case. * Class for a block serialization test case.
*/ */
@@ -45,13 +45,12 @@ class SerializationTestCase {
*/ */
assertBlockStructure(block) {} assertBlockStructure(block) {}
} }
exports.SerializationTestCase = SerializationTestCase;
/** /**
* Runs serialization test suite. * Runs serialization test suite.
* @param {!Array<!SerializationTestCase>} testCases The test cases to run. * @param {!Array<!SerializationTestCase>} testCases The test cases to run.
*/ */
const runSerializationTestSuite = (testCases) => { export const runSerializationTestSuite = (testCases) => {
/** /**
* Creates test callback for xmlToBlock test. * Creates test callback for xmlToBlock test.
* @param {!SerializationTestCase} testCase The test case information. * @param {!SerializationTestCase} testCase The test case information.
@@ -129,4 +128,3 @@ const runSerializationTestSuite = (testCases) => {
}); });
}); });
}; };
exports.runSerializationTestSuite = runSerializationTestSuite;

View File

@@ -4,11 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.helpers.setupTeardown'); goog.declareModuleId('Blockly.test.helpers.setupTeardown');
const eventUtils = goog.require('Blockly.Events.utils');
const {Blocks} = goog.require('Blockly.blocks');
import * as eventUtils from '../../../build/src/core/events/utils.js';
/** /**
* Safely disposes of Blockly workspace, logging any errors. * Safely disposes of Blockly workspace, logging any errors.
@@ -16,7 +14,7 @@ const {Blocks} = goog.require('Blockly.blocks');
* using workspaceTeardown.call(this). * using workspaceTeardown.call(this).
* @param {!Blockly.Workspace} workspace The workspace to dispose. * @param {!Blockly.Workspace} workspace The workspace to dispose.
*/ */
function workspaceTeardown(workspace) { export function workspaceTeardown(workspace) {
try { try {
this.clock.runAll(); // Run all queued setTimeout calls. this.clock.runAll(); // Run all queued setTimeout calls.
workspace.dispose(); workspace.dispose();
@@ -26,7 +24,6 @@ function workspaceTeardown(workspace) {
console.error(testRef.fullTitle() + '\n', e); console.error(testRef.fullTitle() + '\n', e);
} }
} }
exports.workspaceTeardown = workspaceTeardown;
/** /**
* Creates stub for Blockly.Events.fire that advances the clock forward after * Creates stub for Blockly.Events.fire that advances the clock forward after
@@ -53,10 +50,9 @@ function createEventsFireStubFireImmediately_(clock) {
* sharedTestSetup. * sharedTestSetup.
* @param {string} message The message to add to shared cleanup object. * @param {string} message The message to add to shared cleanup object.
*/ */
function addMessageToCleanup(sharedCleanupObj, message) { export function addMessageToCleanup(sharedCleanupObj, message) {
sharedCleanupObj.messagesCleanup_.push(message); sharedCleanupObj.messagesCleanup_.push(message);
} }
exports.addMessageToCleanup = addMessageToCleanup;
/** /**
* Adds block type to shared cleanup object so that it is cleaned from * Adds block type to shared cleanup object so that it is cleaned from
@@ -65,10 +61,9 @@ exports.addMessageToCleanup = addMessageToCleanup;
* sharedTestSetup. * sharedTestSetup.
* @param {string} blockType The block type to add to shared cleanup object. * @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); sharedCleanupObj.blockTypesCleanup_.push(blockType);
} }
exports.addBlockTypeToCleanup = addBlockTypeToCleanup;
/** /**
* Wraps Blockly.defineBlocksWithJsonArray using stub in order to keep track of * Wraps Blockly.defineBlocksWithJsonArray using stub in order to keep track of
@@ -111,7 +106,7 @@ function wrapDefineBlocksWithJsonArrayWithCleanup_(sharedCleanupObj) {
* @param {Object<string, boolean>} options Options to enable/disable setup * @param {Object<string, boolean>} options Options to enable/disable setup
* of certain stubs. * of certain stubs.
*/ */
function sharedTestSetup(options = {}) { export function sharedTestSetup(options = {}) {
this.sharedSetupCalled_ = true; this.sharedSetupCalled_ = true;
// Sandbox created for greater control when certain stubs are cleared. // Sandbox created for greater control when certain stubs are cleared.
this.sharedSetupSandbox_ = sinon.createSandbox(); this.sharedSetupSandbox_ = sinon.createSandbox();
@@ -128,14 +123,13 @@ function sharedTestSetup(options = {}) {
this.messagesCleanup_ = this.sharedCleanup.messagesCleanup_; this.messagesCleanup_ = this.sharedCleanup.messagesCleanup_;
wrapDefineBlocksWithJsonArrayWithCleanup_(this.sharedCleanup); wrapDefineBlocksWithJsonArrayWithCleanup_(this.sharedCleanup);
} }
exports.sharedTestSetup = sharedTestSetup;
/** /**
* Shared cleanup method that clears up pending setTimeout calls, disposes of * Shared cleanup method that clears up pending setTimeout calls, disposes of
* workspace, and resets global variables. Should be called in setup of * workspace, and resets global variables. Should be called in setup of
* outermost suite using sharedTestTeardown.call(this). * outermost suite using sharedTestTeardown.call(this).
*/ */
function sharedTestTeardown() { export function sharedTestTeardown() {
const testRef = this.currentTest || this.test; const testRef = this.currentTest || this.test;
if (!this.sharedSetupCalled_) { if (!this.sharedSetupCalled_) {
console.error('"' + testRef.fullTitle() + '" did not call sharedTestSetup'); console.error('"' + testRef.fullTitle() + '" did not call sharedTestSetup');
@@ -173,7 +167,7 @@ function sharedTestTeardown() {
const blockTypes = this.sharedCleanup.blockTypesCleanup_; const blockTypes = this.sharedCleanup.blockTypesCleanup_;
for (let i = 0; i < blockTypes.length; i++) { for (let i = 0; i < blockTypes.length; i++) {
delete Blocks[blockTypes[i]]; delete Blockly.Blocks[blockTypes[i]];
} }
const messages = this.sharedCleanup.messagesCleanup_; const messages = this.sharedCleanup.messagesCleanup_;
for (let i = 0; i < messages.length; i++) { for (let i = 0; i < messages.length; i++) {
@@ -183,7 +177,6 @@ function sharedTestTeardown() {
Blockly.WidgetDiv.testOnly_setDiv(null); Blockly.WidgetDiv.testOnly_setDiv(null);
} }
} }
exports.sharedTestTeardown = sharedTestTeardown;
/** /**
* Creates stub for Blockly.utils.genUid that returns the provided id or ids. * Creates stub for Blockly.utils.genUid that returns the provided id or ids.
@@ -194,7 +187,7 @@ exports.sharedTestTeardown = sharedTestTeardown;
* that value. * that value.
* @return {!SinonStub} The created stub. * @return {!SinonStub} The created stub.
*/ */
function createGenUidStubWithReturns(returnIds) { export function createGenUidStubWithReturns(returnIds) {
const stub = sinon.stub(Blockly.utils.idGenerator.TEST_ONLY, "genUid"); const stub = sinon.stub(Blockly.utils.idGenerator.TEST_ONLY, "genUid");
if (Array.isArray(returnIds)) { if (Array.isArray(returnIds)) {
for (let i = 0; i < returnIds.length; i++) { for (let i = 0; i < returnIds.length; i++) {
@@ -205,4 +198,3 @@ function createGenUidStubWithReturns(returnIds) {
} }
return stub; return stub;
} }
exports.createGenUidStubWithReturns = createGenUidStubWithReturns;

View File

@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * 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 * @return {Blockly.utils.toolbox.ToolboxJson} The array holding information
* for a toolbox. * for a toolbox.
*/ */
function getCategoryJSON() { export function getCategoryJSON() {
return {"contents": [ return {"contents": [
{ {
"kind": "CATEGORY", "kind": "CATEGORY",
@@ -42,14 +42,13 @@ function getCategoryJSON() {
"name": "Second", "name": "Second",
}]}; }]};
} }
exports.getCategoryJSON = getCategoryJSON;
/** /**
* Get JSON for a simple toolbox. * Get JSON for a simple toolbox.
* @return {Blockly.utils.toolbox.ToolboxJson} The array holding information * @return {Blockly.utils.toolbox.ToolboxJson} The array holding information
* for a simple toolbox. * for a simple toolbox.
*/ */
function getSimpleJson() { export function getSimpleJson() {
return {"contents": [ return {"contents": [
{ {
"kind": "BLOCK", "kind": "BLOCK",
@@ -83,9 +82,8 @@ function getSimpleJson() {
}, },
]}; ]};
} }
exports.getSimpleJson = getSimpleJson;
function getProperSimpleJson() { export function getProperSimpleJson() {
return { return {
"contents": [ "contents": [
{ {
@@ -128,14 +126,13 @@ function getProperSimpleJson() {
}, },
]}; ]};
} }
exports.getProperSimpleJson = getProperSimpleJson;
/** /**
* Get JSON for a toolbox that contains categories that contain categories. * Get JSON for a toolbox that contains categories that contain categories.
* @return {Blockly.utils.toolbox.ToolboxJson} The array holding information * @return {Blockly.utils.toolbox.ToolboxJson} The array holding information
* for a toolbox. * for a toolbox.
*/ */
function getDeeplyNestedJSON() { export function getDeeplyNestedJSON() {
return {"contents": [ return {"contents": [
{ {
"kind": "CATEGORY", "kind": "CATEGORY",
@@ -173,13 +170,12 @@ function getDeeplyNestedJSON() {
"name": "Second", "name": "Second",
}]}; }]};
} }
exports.getDeeplyNestedJSON = getDeeplyNestedJSON;
/** /**
* Get an array filled with xml elements. * Get an array filled with xml elements.
* @return {Array<Node>} Array holding xml elements for a toolbox. * @return {Array<Node>} Array holding xml elements for a toolbox.
*/ */
function getXmlArray() { export function getXmlArray() {
const block = Blockly.Xml.textToDom( const block = Blockly.Xml.textToDom(
`<block type="logic_compare"> `<block type="logic_compare">
<field name="OP">NEQ</field> <field name="OP">NEQ</field>
@@ -199,9 +195,8 @@ function getXmlArray() {
const label = Blockly.Xml.textToDom('<label text="tooltips"></label>'); const label = Blockly.Xml.textToDom('<label text="tooltips"></label>');
return [block, separator, button, label]; return [block, separator, button, label];
} }
exports.getXmlArray = getXmlArray;
function getInjectedToolbox() { export function getInjectedToolbox() {
/** /**
* Category: First * Category: First
* sep * sep
@@ -221,18 +216,16 @@ function getInjectedToolbox() {
}); });
return workspace.getToolbox(); return workspace.getToolbox();
} }
exports.getInjectedToolbox = getInjectedToolbox;
function getBasicToolbox() { export function getBasicToolbox() {
const workspace = new Blockly.WorkspaceSvg(new Blockly.Options({})); const workspace = new Blockly.WorkspaceSvg(new Blockly.Options({}));
const toolbox = new Blockly.Toolbox(workspace); const toolbox = new Blockly.Toolbox(workspace);
toolbox.HtmlDiv = document.createElement('div'); toolbox.HtmlDiv = document.createElement('div');
toolbox.flyout_ = sinon.createStubInstance(Blockly.VerticalFlyout); toolbox.flyout_ = sinon.createStubInstance(Blockly.VerticalFlyout);
return toolbox; return toolbox;
} }
exports.getBasicToolbox = getBasicToolbox;
function getCollapsibleItem(toolbox) { export function getCollapsibleItem(toolbox) {
const contents = toolbox.contents_; const contents = toolbox.contents_;
for (let i = 0; i < contents.length; i++) { for (let i = 0; i < contents.length; i++) {
const item = contents[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_; const contents = toolbox.contents_;
for (let i = 0; i < contents.length; i++) { for (let i = 0; i < contents.length; i++) {
const item = contents[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'); return toolbox.getToolboxItemById('nestedCategory');
} }
exports.getChildItem = getChildItem;
function getSeparator(toolbox) { export function getSeparator(toolbox) {
return toolbox.getToolboxItemById('separator'); return toolbox.getToolboxItemById('separator');
} }
exports.getSeparator = getSeparator;

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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<string, string>=} properties Properties to pass into event * @param {Object<string, string>=} properties Properties to pass into event
* constructor. * constructor.
*/ */
function dispatchPointerEvent(target, type, properties) { export function dispatchPointerEvent(target, type, properties) {
const eventInitDict = { const eventInitDict = {
cancelable: true, cancelable: true,
bubbles: true, bubbles: true,
@@ -32,7 +32,6 @@ function dispatchPointerEvent(target, type, properties) {
const event = new PointerEvent(type, eventInitDict); const event = new PointerEvent(type, eventInitDict);
target.dispatchEvent(event); target.dispatchEvent(event);
} }
exports.dispatchPointerEvent = dispatchPointerEvent;
/** /**
* Creates a key down event used for testing. * Creates a key down event used for testing.
@@ -40,7 +39,7 @@ exports.dispatchPointerEvent = dispatchPointerEvent;
* @param {!Array<number>=} modifiers A list of modifiers. Use Blockly.utils.KeyCodes enum. * @param {!Array<number>=} modifiers A list of modifiers. Use Blockly.utils.KeyCodes enum.
* @return {!KeyboardEvent} The mocked keydown event. * @return {!KeyboardEvent} The mocked keydown event.
*/ */
function createKeyDownEvent(keyCode, modifiers) { export function createKeyDownEvent(keyCode, modifiers) {
const event = { const event = {
keyCode: keyCode, keyCode: keyCode,
}; };
@@ -52,7 +51,6 @@ function createKeyDownEvent(keyCode, modifiers) {
} }
return new KeyboardEvent('keydown', event); return new KeyboardEvent('keydown', event);
} }
exports.createKeyDownEvent = createKeyDownEvent;
/** /**
* Simulates mouse click by triggering relevant mouse events. * Simulates mouse click by triggering relevant mouse events.
@@ -60,9 +58,8 @@ exports.createKeyDownEvent = createKeyDownEvent;
* @param {Object<string, string>=} properties Properties to pass into event * @param {Object<string, string>=} properties Properties to pass into event
* constructor. * constructor.
*/ */
function simulateClick(target, properties) { export function simulateClick(target, properties) {
dispatchPointerEvent(target, 'pointerdown', properties); dispatchPointerEvent(target, 'pointerdown', properties);
dispatchPointerEvent(target, 'pointerup', properties); dispatchPointerEvent(target, 'pointerup', properties);
dispatchPointerEvent(target, 'click', properties); dispatchPointerEvent(target, 'click', properties);
} }
exports.simulateClick = simulateClick;

View File

@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * 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} type The expected type of the variable.
* @param {!string} id The expected id 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); const variable = container.getVariableById(id);
chai.assert.isDefined(variable); chai.assert.isDefined(variable);
chai.assert.equal(variable.name, name); chai.assert.equal(variable.name, name);
chai.assert.equal(variable.type, type); chai.assert.equal(variable.type, type);
chai.assert.equal(variable.getId(), id); chai.assert.equal(variable.getId(), id);
} }
exports.assertVariableValues = assertVariableValues;

View File

@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * 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. * @param {Function} innerFunc The function where warnings may called.
* @return {Array<string>} The warning messages (only the first arguments). * @return {Array<string>} The warning messages (only the first arguments).
*/ */
function captureWarnings(innerFunc) { export function captureWarnings(innerFunc) {
const msgs = []; const msgs = [];
const nativeConsoleWarn = console.warn; const nativeConsoleWarn = console.warn;
try { try {
@@ -26,7 +26,6 @@ function captureWarnings(innerFunc) {
} }
return msgs; return msgs;
} }
exports.captureWarnings = captureWarnings;
/** /**
* Asserts that the given function logs the provided warning messages. * Asserts that the given function logs the provided warning messages.
@@ -34,7 +33,7 @@ exports.captureWarnings = captureWarnings;
* @param {Array<!RegExp>|!RegExp} messages A list of regex for the expected * @param {Array<!RegExp>|!RegExp} messages A list of regex for the expected
* messages (in the expected order). * messages (in the expected order).
*/ */
function assertWarnings(innerFunc, messages) { export function assertWarnings(innerFunc, messages) {
if (!Array.isArray(messages)) { if (!Array.isArray(messages)) {
messages = [messages]; messages = [messages];
} }
@@ -44,25 +43,22 @@ function assertWarnings(innerFunc, messages) {
chai.assert.match(warnings[i], message); chai.assert.match(warnings[i], message);
}); });
} }
exports.assertWarnings = assertWarnings;
/** /**
* Asserts that the given function logs no warning messages. * Asserts that the given function logs no warning messages.
* @param {function()} innerFunc The function to call. * @param {function()} innerFunc The function to call.
*/ */
function assertNoWarnings(innerFunc) { export function assertNoWarnings(innerFunc) {
assertWarnings(innerFunc, []); assertWarnings(innerFunc, []);
} }
exports.assertNoWarnings = assertNoWarnings;
/** /**
* Stubs Blockly.utils.deprecation.warn call. * Stubs Blockly.utils.deprecation.warn call.
* @return {!SinonStub} The created stub. * @return {!SinonStub} The created stub.
*/ */
function createDeprecationWarningStub() { export function createDeprecationWarningStub() {
return sinon.stub(Blockly.utils.deprecation, 'warn'); return sinon.stub(Blockly.utils.deprecation, 'warn');
} }
exports.createDeprecationWarningStub = createDeprecationWarningStub;
/** /**
* Asserts whether the given deprecation warning stub or call was called with * 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 * @param {string} functionName The function name to check that the given spy or
* spy call was called with. * spy call was called with.
*/ */
function assertDeprecationWarningCall(spyOrSpyCall, functionName) { export function assertDeprecationWarningCall(spyOrSpyCall, functionName) {
sinon.assert.calledWith(spyOrSpyCall, functionName); sinon.assert.calledWith(spyOrSpyCall, functionName);
} }
exports.assertDeprecationWarningCall = assertDeprecationWarningCall;
/** /**
* Asserts that there was a single deprecation warning call with the given * 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 * @param {string} functionName The function name to check that the given spy
* was called with. * was called with.
*/ */
function assertSingleDeprecationWarningCall(spy, functionName) { export function assertSingleDeprecationWarningCall(spy, functionName) {
sinon.assert.calledOnce(spy); sinon.assert.calledOnce(spy);
assertDeprecationWarningCall(spy.getCall(0), functionName); assertDeprecationWarningCall(spy.getCall(0), functionName);
} }
exports.assertSingleDeprecationWarningCall = assertSingleDeprecationWarningCall;

View File

@@ -4,15 +4,15 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {assertVariableValues} from './variables.js';
const {assertWarnings} = goog.require('Blockly.test.helpers.warnings'); import {assertWarnings} from './warnings.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../../build/src/core/events/utils.js';
const {workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {workspaceTeardown} from './setup_teardown.js';
function testAWorkspace() { export function testAWorkspace() {
setup(function() { setup(function() {
Blockly.defineBlocksWithJsonArray([{ Blockly.defineBlocksWithJsonArray([{
"type": "get_var_block", "type": "get_var_block",
@@ -1528,4 +1528,3 @@ function testAWorkspace() {
}); });
}); });
} }
exports.testAWorkspace = testAWorkspace;

View File

@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.theme'); goog.declareModuleId('Blockly.test.theme');
const {assertEventFired} = goog.require('Blockly.test.helpers.events'); import {assertEventFired} from './test_helpers/events.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
suite('Theme', function() { suite('Theme', function() {

View File

@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.toolbox'); goog.declareModuleId('Blockly.test.toolbox');
const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {defineStackBlock} from './test_helpers/block_definitions.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
const {getBasicToolbox, getCategoryJSON, getChildItem, getCollapsibleItem, getDeeplyNestedJSON, getInjectedToolbox, getNonCollapsibleItem, getSeparator, getSimpleJson, getXmlArray} = goog.require('Blockly.test.helpers.toolboxDefinitions'); import {getBasicToolbox, getCategoryJSON, getChildItem, getCollapsibleItem, getDeeplyNestedJSON, getInjectedToolbox, getNonCollapsibleItem, getSeparator, getSimpleJson, getXmlArray} from './test_helpers/toolbox_definitions.js';
suite('Toolbox', function() { suite('Toolbox', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Tooltip', function() {

View File

@@ -4,13 +4,13 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {assertEventFired, assertEventNotFired} from './test_helpers/events.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
const {defineBasicBlockWithField, defineMutatorBlocks, defineRowBlock, defineStackBlock, defineStatementBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {defineBasicBlockWithField, defineMutatorBlocks, defineRowBlock, defineStackBlock, defineStatementBlock} from './test_helpers/block_definitions.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
const {simulateClick} = goog.require('Blockly.test.helpers.userInput'); import {simulateClick} from './test_helpers/user_input.js';
suite("Trashcan", function() { suite("Trashcan", function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Utils', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.variableMap'); goog.declareModuleId('Blockly.test.variableMap');
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); import {assertVariableValues} from './test_helpers/variables.js';
const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Variable Map', function() { suite('Variable Map', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('Variable Model', function() {

View File

@@ -4,9 +4,9 @@
* SPDX-License-Identifier: Apache-2.0 * 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() { suite('WidgetDiv', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.workspaceComment'); goog.declareModuleId('Blockly.test.workspaceComment');
goog.require('Blockly.WorkspaceComment'); import {WorkspaceComment} from '../../build/src/core/workspace_comment.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
suite('Workspace comment', function() { suite('Workspace comment', function() {

View File

@@ -4,14 +4,14 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {assertEventFired, assertEventNotFired, createFireChangeListenerSpy} from './test_helpers/events.js';
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); import {assertVariableValues} from './test_helpers/variables.js';
const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions'); import {defineStackBlock} from './test_helpers/block_definitions.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
const {testAWorkspace} = goog.require('Blockly.test.helpers.workspace'); import {testAWorkspace} from './test_helpers/workspace.js';
suite('WorkspaceSvg', function() { suite('WorkspaceSvg', function() {

View File

@@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
goog.module('Blockly.test.workspace'); goog.declareModuleId('Blockly.test.workspace');
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); import {assertVariableValues} from './test_helpers/variables.js';
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
const {testAWorkspace} = goog.require('Blockly.test.helpers.workspace'); import {testAWorkspace} from './test_helpers/workspace.js';
suite('Workspace', function() { suite('Workspace', function() {

View File

@@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {addBlockTypeToCleanup, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} from './test_helpers/setup_teardown.js';
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables'); import {assertVariableValues} from './test_helpers/variables.js';
suite('XML', function() { suite('XML', function() {

View File

@@ -4,12 +4,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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'); import {assertEventFired, assertEventNotFired} from './test_helpers/events.js';
const eventUtils = goog.require('Blockly.Events.utils'); import * as eventUtils from '../../build/src/core/events/utils.js';
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown'); import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
const {simulateClick} = goog.require('Blockly.test.helpers.userInput'); import {simulateClick} from './test_helpers/user_input.js';
suite("Zoom Controls", function() { suite("Zoom Controls", function() {