fix: split variable helper into new file

This commit is contained in:
Beka Westberg
2022-03-01 20:15:33 +00:00
parent e1ad627430
commit 07663706ee
10 changed files with 45 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ goog.addDependency('../../tests/mocha/connection_test.js', ['Blockly.test.connec
goog.addDependency('../../tests/mocha/contextmenu_items_test.js', ['Blockly.test.contextMenuItem'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/cursor_test.js', ['Blockly.test.cursor'], ['Blockly.ASTNode', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/dropdowndiv_test.js', ['Blockly.test.dropdown'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/event_test.js', ['Blockly.test.event'], ['Blockly.ASTNode', 'Blockly.Events.utils', 'Blockly.WorkspaceComment', 'Blockly.test.helpers', 'Blockly.test.helpers.events'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/event_test.js', ['Blockly.test.event'], ['Blockly.ASTNode', 'Blockly.Events.utils', 'Blockly.WorkspaceComment', 'Blockly.test.helpers', 'Blockly.test.helpers.events', 'Blockly.test.helpers.variables'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/extensions_test.js', ['Blockly.test.extensions'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/field_angle_test.js', ['Blockly.test.fieldAngle'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/field_checkbox_test.js', ['Blockly.test.fieldCheckbox'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.fields'], {'lang': 'es6', 'module': 'goog'});
@@ -54,19 +54,20 @@ goog.addDependency('../../tests/mocha/test_helpers/serialization.js', ['Blockly.
goog.addDependency('../../tests/mocha/test_helpers/test_helpers.js', ['Blockly.test.helpers'], ['Blockly.Events.utils', 'Blockly.blocks'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/test_helpers/toolbox_definitions.js', ['Blockly.test.helpers.toolbox_definitions'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/test_helpers/user_input.js', ['Blockly.test.helpers.userInput'], ['Blockly.utils.KeyCodes'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/test_helpers/variables.js', ['Blockly.test.helpers.variables'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/test_helpers/warnings.js', ['Blockly.test.helpers.warnings'], ['Blockly.Events.utils', 'Blockly.blocks', 'Blockly.test.helpers.common', 'Blockly.utils.KeyCodes'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/test_helpers/workspace.js', ['Blockly.test.helpers.workspace'], ['Blockly.Events.utils', 'Blockly.test.helpers', 'Blockly.test.helpers.warnings'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/test_helpers/workspace.js', ['Blockly.test.helpers.workspace'], ['Blockly.Events.utils', 'Blockly.test.helpers', 'Blockly.test.helpers.variables', 'Blockly.test.helpers.warnings'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/theme_test.js', ['Blockly.test.theme'], ['Blockly.Events.utils', 'Blockly.test.helpers', 'Blockly.test.helpers.events'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/toolbox_test.js', ['Blockly.test.toolbox'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.toolbox_definitions'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/tooltip_test.js', ['Blockly.test.tooltip'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/trashcan_test.js', ['Blockly.test.trashcan'], ['Blockly.Events.utils', 'Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.events', 'Blockly.test.helpers.userInput'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/utils_test.js', ['Blockly.test.utils'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/variable_map_test.js', ['Blockly.test.variableMap'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/variable_map_test.js', ['Blockly.test.variableMap'], ['Blockly.test.helpers', 'Blockly.test.helpers.variables'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/variable_model_test.js', ['Blockly.test.variableModel'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/variables_test.js', ['Blockly.test.variables'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/widget_div_test.js', ['Blockly.test.widgetDiv'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/workspace_comment_test.js', ['Blockly.test.workspaceComment'], ['Blockly.WorkspaceComment', 'Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/workspace_svg_test.js', ['Blockly.test.workspaceSvg'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.events', 'Blockly.test.helpers.workspace'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/workspace_test.js', ['Blockly.test.workspace'], ['Blockly.test.helpers', 'Blockly.test.helpers.workspace'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/xml_test.js', ['Blockly.test.xml'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/workspace_svg_test.js', ['Blockly.test.workspaceSvg'], ['Blockly.test.helpers', 'Blockly.test.helpers.blockDefinitions', 'Blockly.test.helpers.events', 'Blockly.test.helpers.variables', 'Blockly.test.helpers.workspace'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/workspace_test.js', ['Blockly.test.workspace'], ['Blockly.test.helpers', 'Blockly.test.helpers.variables', 'Blockly.test.helpers.workspace'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/xml_test.js', ['Blockly.test.xml'], ['Blockly.test.helpers', 'Blockly.test.helpers.variables'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../tests/mocha/zoom_controls_test.js', ['Blockly.test.zoomControls'], ['Blockly.Events.utils', 'Blockly.test.helpers', 'Blockly.test.helpers.events', 'Blockly.test.helpers.userInput'], {'lang': 'es6', 'module': 'goog'});

View File

@@ -7,8 +7,9 @@
goog.module('Blockly.test.event');
const {ASTNode} = goog.require('Blockly.ASTNode');
const {assertVariableValues, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
const {assertEventEquals, assertNthCallEventArgEquals, createFireChangeListenerSpy} = goog.require('Blockly.test.helpers.events');
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables');
const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
const eventUtils = goog.require('Blockly.Events.utils');
goog.require('Blockly.WorkspaceComment');

View File

@@ -10,23 +10,6 @@ const eventUtils = goog.require('Blockly.Events.utils');
const {Blocks} = goog.require('Blockly.blocks');
/**
* Check if a variable with the given values exists.
* @param {Blockly.Workspace|Blockly.VariableMap} container The workspace or
* variableMap the checked variable belongs to.
* @param {!string} name The expected name of the variable.
* @param {!string} type The expected type of the variable.
* @param {!string} id The expected id of the variable.
*/
function assertVariableValues(container, name, type, id) {
const variable = container.getVariableById(id);
chai.assert.isDefined(variable);
chai.assert.equal(variable.name, name);
chai.assert.equal(variable.type, type);
chai.assert.equal(variable.getId(), id);
}
exports.assertVariableValues = assertVariableValues;
/**
* Safely disposes of Blockly workspace, logging any errors.
* Assumes that sharedTestSetup has also been called. This should be called

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.module('Blockly.test.helpers.variables');
/**
* Check if a variable with the given values exists.
* @param {Blockly.Workspace|Blockly.VariableMap} container The workspace or
* variableMap the checked variable belongs to.
* @param {!string} name The expected name of the variable.
* @param {!string} type The expected type of the variable.
* @param {!string} id The expected id of the variable.
*/
function assertVariableValues(container, name, type, id) {
const variable = container.getVariableById(id);
chai.assert.isDefined(variable);
chai.assert.equal(variable.name, name);
chai.assert.equal(variable.type, type);
chai.assert.equal(variable.getId(), id);
}
exports.assertVariableValues = assertVariableValues;

View File

@@ -6,9 +6,10 @@
goog.module('Blockly.test.helpers.workspace');
const {assertVariableValues, workspaceTeardown} = goog.require('Blockly.test.helpers');
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables');
const {assertWarnings} = goog.require('Blockly.test.helpers.warnings');
const eventUtils = goog.require('Blockly.Events.utils');
const {workspaceTeardown} = goog.require('Blockly.test.helpers');
function testAWorkspace() {

View File

@@ -6,8 +6,8 @@
goog.module('Blockly.test.theme');
const eventUtils = goog.require('Blockly.Events.utils');
const {assertEventFired} = goog.require('Blockly.test.helpers.events');
const eventUtils = goog.require('Blockly.Events.utils');
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');

View File

@@ -6,7 +6,8 @@
goog.module('Blockly.test.variableMap');
const {assertVariableValues, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers');
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables');
const {createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers');
suite('Variable Map', function() {

View File

@@ -7,8 +7,9 @@
goog.module('Blockly.test.workspaceSvg');
const {assertEventFired, assertEventNotFired, createFireChangeListenerSpy} = goog.require('Blockly.test.helpers.events');
const {assertVariableValues, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables');
const {defineStackBlock} = goog.require('Blockly.test.helpers.blockDefinitions');
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
const {testAWorkspace} = goog.require('Blockly.test.helpers.workspace');

View File

@@ -6,7 +6,8 @@
goog.module('Blockly.test.workspace');
const {assertVariableValues, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables');
const {sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
const {testAWorkspace} = goog.require('Blockly.test.helpers.workspace');

View File

@@ -6,7 +6,8 @@
goog.module('Blockly.test.xml');
const {addBlockTypeToCleanup, assertVariableValues, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
const {addBlockTypeToCleanup, createGenUidStubWithReturns, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers');
const {assertVariableValues} = goog.require('Blockly.test.helpers.variables');
suite('XML', function() {