From 1174777b7ccc69b0f935ed79bad876b0d81ca6bc Mon Sep 17 00:00:00 2001 From: jayway <70596906+jibranabsarulislam@users.noreply.github.com> Date: Fri, 23 Jun 2023 14:16:34 -0400 Subject: [PATCH] fix: Utilize getIcon instead of getCommentIcon in tests (#7200) * fix: refactor getCommentIcon to getIcon and remove warning * format & lint (please squash) * revert changes to block_svg.ts until v11 --- tests/mocha/comment_deserialization_test.js | 3 ++- tests/mocha/contextmenu_items_test.js | 5 +++-- tests/mocha/xml_test.js | 18 +++++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/mocha/comment_deserialization_test.js b/tests/mocha/comment_deserialization_test.js index 42ae34954..08fe164b3 100644 --- a/tests/mocha/comment_deserialization_test.js +++ b/tests/mocha/comment_deserialization_test.js @@ -10,6 +10,7 @@ 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 () { @@ -61,7 +62,7 @@ suite('Comment Deserialization', function () { const icon = block.getIcon(Blockly.icons.CommentIcon.TYPE); icon.setBubbleVisible(true); // Check comment bubble size. - const comment = block.getCommentIcon(); + const comment = block.getIcon(CommentIcon.TYPE); const bubbleSize = comment.getBubbleSize(); chai.assert.isNotNaN(bubbleSize.width); chai.assert.isNotNaN(bubbleSize.height); diff --git a/tests/mocha/contextmenu_items_test.js b/tests/mocha/contextmenu_items_test.js index 63ee54b13..4c551742b 100644 --- a/tests/mocha/contextmenu_items_test.js +++ b/tests/mocha/contextmenu_items_test.js @@ -11,6 +11,7 @@ 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,11 +460,11 @@ suite('Context Menu Items', function () { test('Creates comment if one did not exist', function () { chai.assert.isNull( - this.block.getCommentIcon(), + this.block.getIcon(CommentIcon.TYPE), 'New block should not have a comment' ); this.commentOption.callback(this.scope); - chai.assert.exists(this.block.getCommentIcon()); + chai.assert.exists(this.block.getIcon(CommentIcon.TYPE)); chai.assert.isEmpty( this.block.getCommentText(), 'Block should have empty comment text' diff --git a/tests/mocha/xml_test.js b/tests/mocha/xml_test.js index 085984ed7..fe4c75050 100644 --- a/tests/mocha/xml_test.js +++ b/tests/mocha/xml_test.js @@ -13,6 +13,7 @@ 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 () { @@ -442,7 +443,7 @@ suite('XML', function () { test('Size', function () { this.block.setCommentText('test text'); this.block - .getCommentIcon() + .getIcon(CommentIcon.TYPE) .setBubbleSize(new Blockly.utils.Size(100, 200)); const xml = Blockly.Xml.blockToDom(this.block); const commentXml = xml.firstChild; @@ -452,7 +453,7 @@ suite('XML', function () { }); test('Pinned True', function () { this.block.setCommentText('test text'); - this.block.getCommentIcon().setBubbleVisible(true); + this.block.getIcon(CommentIcon.TYPE).setBubbleVisible(true); const xml = Blockly.Xml.blockToDom(this.block); const commentXml = xml.firstChild; chai.assert.equal(commentXml.tagName, 'comment'); @@ -697,7 +698,7 @@ suite('XML', function () { this.workspace ); chai.assert.equal(block.getCommentText(), 'test text'); - chai.assert.isOk(block.getCommentIcon()); + chai.assert.isOk(block.getIcon(CommentIcon.TYPE)); }); test('No Text', function () { const block = Blockly.Xml.domToBlock( @@ -721,10 +722,13 @@ suite('XML', function () { this.workspace ); chai.assert.isOk(block.getIcon(Blockly.icons.CommentIcon.TYPE)); - chai.assert.deepEqual(block.getCommentIcon().getBubbleSize(), { - width: 100, - height: 200, - }); + chai.assert.deepEqual( + block.getIcon(CommentIcon.TYPE).getBubbleSize(), + { + width: 100, + height: 200, + } + ); }); suite('Pinned', function () { test('Pinned True', function () {