feat: add types for accessing icons. (#7132)

* feat: add types for accessing icons.

* chore: PR comments
This commit is contained in:
Beka Westberg
2023-06-13 14:39:36 -07:00
committed by GitHub
parent 22a7a7bbab
commit 0cfd388a5d
15 changed files with 72 additions and 60 deletions

View File

@@ -1443,7 +1443,7 @@ suite('Blocks', function () {
suite('Icon management', function () {
class MockIconA extends MockIcon {
getType() {
return 'A';
return new Blockly.icons.IconType('A');
}
getWeight() {
@@ -1453,7 +1453,7 @@ suite('Blocks', function () {
class MockIconB extends MockIcon {
getType() {
return 'B';
return new Blockly.icons.IconType('B');
}
getWeight() {
@@ -1524,7 +1524,7 @@ suite('Blocks', function () {
test('icons get removed from the block', function () {
this.block.addIcon(new MockIconA());
chai.assert.isTrue(
this.block.removeIcon('A'),
this.block.removeIcon(new Blockly.icons.IconType('A')),
'Expected removeIcon to return true'
);
chai.assert.isFalse(
@@ -1535,7 +1535,7 @@ suite('Blocks', function () {
test('removing an icon that does not exist returns false', function () {
chai.assert.isFalse(
this.block.removeIcon('B'),
this.block.removeIcon(new Blockly.icons.IconType('B')),
'Expected removeIcon to return false'
);
});
@@ -1543,7 +1543,7 @@ suite('Blocks', function () {
test('removing an icon triggers a render', function () {
this.block.addIcon(new MockIconA());
this.renderSpy.resetHistory();
this.block.removeIcon('A');
this.block.removeIcon(new Blockly.icons.IconType('A'));
chai.assert.isTrue(
this.renderSpy.calledOnce,
'Expected removing an icon to trigger a render'

View File

@@ -6,7 +6,7 @@
export class MockIcon {
getType() {
return 'mock icon';
return new Blockly.icons.IconType('mock icon');
}
initView() {}
@@ -43,7 +43,7 @@ export class MockSerializableIcon extends MockIcon {
}
getType() {
return 'serializable icon';
return new Blockly.icons.IconType('serializable icon');
}
getWeight() {
@@ -66,7 +66,7 @@ export class MockBubbleIcon extends MockIcon {
}
getType() {
return 'bubble icon';
return new Blockly.icons.IconType('bubble icon');
}
updateCollapsed() {}