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

@@ -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,