Skip to content

Commit 1174777

Browse files
authored
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
1 parent acbe2c6 commit 1174777

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

tests/mocha/comment_deserialization_test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
sharedTestSetup,
1111
sharedTestTeardown,
1212
} from './test_helpers/setup_teardown.js';
13+
import {CommentIcon} from '../../core/icons/comment_icon.js';
1314
import {simulateClick} from './test_helpers/user_input.js';
1415

1516
suite('Comment Deserialization', function () {
@@ -61,7 +62,7 @@ suite('Comment Deserialization', function () {
6162
const icon = block.getIcon(Blockly.icons.CommentIcon.TYPE);
6263
icon.setBubbleVisible(true);
6364
// Check comment bubble size.
64-
const comment = block.getCommentIcon();
65+
const comment = block.getIcon(CommentIcon.TYPE);
6566
const bubbleSize = comment.getBubbleSize();
6667
chai.assert.isNotNaN(bubbleSize.width);
6768
chai.assert.isNotNaN(bubbleSize.height);

tests/mocha/contextmenu_items_test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
sharedTestTeardown,
1212
workspaceTeardown,
1313
} from './test_helpers/setup_teardown.js';
14+
import {CommentIcon} from '../../core/icons/comment_icon.js';
1415

1516
suite('Context Menu Items', function () {
1617
setup(function () {
@@ -459,11 +460,11 @@ suite('Context Menu Items', function () {
459460

460461
test('Creates comment if one did not exist', function () {
461462
chai.assert.isNull(
462-
this.block.getCommentIcon(),
463+
this.block.getIcon(CommentIcon.TYPE),
463464
'New block should not have a comment'
464465
);
465466
this.commentOption.callback(this.scope);
466-
chai.assert.exists(this.block.getCommentIcon());
467+
chai.assert.exists(this.block.getIcon(CommentIcon.TYPE));
467468
chai.assert.isEmpty(
468469
this.block.getCommentText(),
469470
'Block should have empty comment text'

tests/mocha/xml_test.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
sharedTestTeardown,
1414
workspaceTeardown,
1515
} from './test_helpers/setup_teardown.js';
16+
import {CommentIcon} from '../../core/icons/comment_icon.js';
1617
import {assertVariableValues} from './test_helpers/variables.js';
1718

1819
suite('XML', function () {
@@ -442,7 +443,7 @@ suite('XML', function () {
442443
test('Size', function () {
443444
this.block.setCommentText('test text');
444445
this.block
445-
.getCommentIcon()
446+
.getIcon(CommentIcon.TYPE)
446447
.setBubbleSize(new Blockly.utils.Size(100, 200));
447448
const xml = Blockly.Xml.blockToDom(this.block);
448449
const commentXml = xml.firstChild;
@@ -452,7 +453,7 @@ suite('XML', function () {
452453
});
453454
test('Pinned True', function () {
454455
this.block.setCommentText('test text');
455-
this.block.getCommentIcon().setBubbleVisible(true);
456+
this.block.getIcon(CommentIcon.TYPE).setBubbleVisible(true);
456457
const xml = Blockly.Xml.blockToDom(this.block);
457458
const commentXml = xml.firstChild;
458459
chai.assert.equal(commentXml.tagName, 'comment');
@@ -697,7 +698,7 @@ suite('XML', function () {
697698
this.workspace
698699
);
699700
chai.assert.equal(block.getCommentText(), 'test text');
700-
chai.assert.isOk(block.getCommentIcon());
701+
chai.assert.isOk(block.getIcon(CommentIcon.TYPE));
701702
});
702703
test('No Text', function () {
703704
const block = Blockly.Xml.domToBlock(
@@ -721,10 +722,13 @@ suite('XML', function () {
721722
this.workspace
722723
);
723724
chai.assert.isOk(block.getIcon(Blockly.icons.CommentIcon.TYPE));
724-
chai.assert.deepEqual(block.getCommentIcon().getBubbleSize(), {
725-
width: 100,
726-
height: 200,
727-
});
725+
chai.assert.deepEqual(
726+
block.getIcon(CommentIcon.TYPE).getBubbleSize(),
727+
{
728+
width: 100,
729+
height: 200,
730+
}
731+
);
728732
});
729733
suite('Pinned', function () {
730734
test('Pinned True', function () {

0 commit comments

Comments
 (0)