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
This commit is contained in:
jayway
2023-06-23 14:16:34 -04:00
committed by GitHub
parent acbe2c6a29
commit 1174777b7c
3 changed files with 16 additions and 10 deletions

View File

@@ -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);

View File

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

View File

@@ -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 () {