fix(tests): Make test imports correct and more consistent (#7260)

* fix(tests): Fix invalid import paths in mocha tests

  This resolves the warnings generated during buildDeps by
  closure-make-deps.

  This commit does not attempt to address #7224 or otherwise
  rationalise the imports and usage thereof.

* fix(tests): Fix failing context menu item test

  Test appears to have been wrong: Block.prototype.getIcon is typed
  as

      getIcon<T extends IIcon>(/* ... */): T | undefined

  and documented as "@returns The icon with the given type if it
  exists on the block, undefined otherwise."

* refactor(tests): Clean up inconsistent usage of CommentIcon

  Tweak the test files touched by PR #7200 to be consistent with
  existing usage of Blockly.icons.CommentIcon instead of importing
  this separately.
This commit is contained in:
Christopher Allen
2023-07-07 17:15:03 +01:00
committed by GitHub
parent 07ba841850
commit aefb97d780
5 changed files with 20 additions and 22 deletions

View File

@@ -10,7 +10,6 @@ import {
sharedTestSetup,
sharedTestTeardown,
} from './test_helpers/setup_teardown.js';
import {CommentIcon} from '../../core/icons/comment_icon.js';
import {simulateClick} from './test_helpers/user_input.js';
suite('Comment Deserialization', function () {
@@ -62,8 +61,7 @@ suite('Comment Deserialization', function () {
const icon = block.getIcon(Blockly.icons.CommentIcon.TYPE);
icon.setBubbleVisible(true);
// Check comment bubble size.
const comment = block.getIcon(CommentIcon.TYPE);
const bubbleSize = comment.getBubbleSize();
const bubbleSize = icon.getBubbleSize();
chai.assert.isNotNaN(bubbleSize.width);
chai.assert.isNotNaN(bubbleSize.height);
chai.assert.equal(icon.getText(), text);

View File

@@ -11,7 +11,6 @@ import {
sharedTestTeardown,
workspaceTeardown,
} from './test_helpers/setup_teardown.js';
import {CommentIcon} from '../../core/icons/comment_icon.js';
suite('Context Menu Items', function () {
setup(function () {
@@ -459,12 +458,12 @@ suite('Context Menu Items', function () {
});
test('Creates comment if one did not exist', function () {
chai.assert.isNull(
this.block.getIcon(CommentIcon.TYPE),
chai.assert.isUndefined(
this.block.getIcon(Blockly.icons.CommentIcon.TYPE),
'New block should not have a comment'
);
this.commentOption.callback(this.scope);
chai.assert.exists(this.block.getIcon(CommentIcon.TYPE));
chai.assert.exists(this.block.getIcon(Blockly.icons.CommentIcon.TYPE));
chai.assert.isEmpty(
this.block.getCommentText(),
'Block should have empty comment text'

View File

@@ -23,11 +23,11 @@ import {
workspaceTeardown,
} from './test_helpers/setup_teardown.js';
import {runCodeGenerationTestSuites} from './test_helpers/code_generation.js';
import {dartGenerator} from '../../generators/dart.js';
import {javascriptGenerator} from '../../generators/javascript.js';
import {luaGenerator} from '../../generators/lua.js';
import {phpGenerator} from '../../generators/php.js';
import {pythonGenerator} from '../../generators/python.js';
import {dartGenerator} from '../../build/src/generators/dart.js';
import {javascriptGenerator} from '../../build/src/generators/javascript.js';
import {luaGenerator} from '../../build/src/generators/lua.js';
import {phpGenerator} from '../../build/src/generators/php.js';
import {pythonGenerator} from '../../build/src/generators/python.js';
suite('Multiline Input Fields', function () {
setup(function () {

View File

@@ -7,11 +7,11 @@
goog.declareModuleId('Blockly.test.generator');
import * as Blockly from '../../build/src/core/blockly.js';
import {DartGenerator} from '../../generators/dart/dart_generator.js';
import {JavascriptGenerator} from '../../generators/javascript/javascript_generator.js';
import {LuaGenerator} from '../../generators/lua/lua_generator.js';
import {PhpGenerator} from '../../generators/php/php_generator.js';
import {PythonGenerator} from '../../generators/python/python_generator.js';
import {DartGenerator} from '../../build/src/generators/dart/dart_generator.js';
import {JavascriptGenerator} from '../../build/src/generators/javascript/javascript_generator.js';
import {LuaGenerator} from '../../build/src/generators/lua/lua_generator.js';
import {PhpGenerator} from '../../build/src/generators/php/php_generator.js';
import {PythonGenerator} from '../../build/src/generators/python/python_generator.js';
import {
sharedTestSetup,
sharedTestTeardown,

View File

@@ -13,7 +13,6 @@ import {
sharedTestTeardown,
workspaceTeardown,
} from './test_helpers/setup_teardown.js';
import {CommentIcon} from '../../core/icons/comment_icon.js';
import {assertVariableValues} from './test_helpers/variables.js';
suite('XML', function () {
@@ -443,7 +442,7 @@ suite('XML', function () {
test('Size', function () {
this.block.setCommentText('test text');
this.block
.getIcon(CommentIcon.TYPE)
.getIcon(Blockly.icons.CommentIcon.TYPE)
.setBubbleSize(new Blockly.utils.Size(100, 200));
const xml = Blockly.Xml.blockToDom(this.block);
const commentXml = xml.firstChild;
@@ -453,7 +452,9 @@ suite('XML', function () {
});
test('Pinned True', function () {
this.block.setCommentText('test text');
this.block.getIcon(CommentIcon.TYPE).setBubbleVisible(true);
this.block
.getIcon(Blockly.icons.CommentIcon.TYPE)
.setBubbleVisible(true);
const xml = Blockly.Xml.blockToDom(this.block);
const commentXml = xml.firstChild;
chai.assert.equal(commentXml.tagName, 'comment');
@@ -698,7 +699,7 @@ suite('XML', function () {
this.workspace
);
chai.assert.equal(block.getCommentText(), 'test text');
chai.assert.isOk(block.getIcon(CommentIcon.TYPE));
chai.assert.isOk(block.getIcon(Blockly.icons.CommentIcon.TYPE));
});
test('No Text', function () {
const block = Blockly.Xml.domToBlock(
@@ -723,7 +724,7 @@ suite('XML', function () {
);
chai.assert.isOk(block.getIcon(Blockly.icons.CommentIcon.TYPE));
chai.assert.deepEqual(
block.getIcon(CommentIcon.TYPE).getBubbleSize(),
block.getIcon(Blockly.icons.CommentIcon.TYPE).getBubbleSize(),
{
width: 100,
height: 200,