Skip to content

Commit 6112b9d

Browse files
committed
refactor: keep capability metadata independent of helper behavior
1 parent 74e5542 commit 6112b9d

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

js/__tests__/block.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,26 @@ describe("Block Foundation", () => {
153153
expect(block.getInfo()).toBe("forward block");
154154
});
155155

156+
it("isCollapsible() should return true for collapsible blocks", () => {
157+
mockProtoBlock.name = "start";
158+
const block = new Block(mockProtoBlock, mockBlocks);
159+
expect(block.isCollapsible()).toBe(true);
160+
161+
mockProtoBlock.name = "forward";
162+
const block2 = new Block(mockProtoBlock, mockBlocks);
163+
expect(block2.isCollapsible()).toBe(false);
164+
});
165+
166+
it("isInlineCollapsible() should return true for inline collapsible blocks", () => {
167+
mockProtoBlock.name = "newnote";
168+
const block = new Block(mockProtoBlock, mockBlocks);
169+
expect(block.isInlineCollapsible()).toBe(true);
170+
171+
mockProtoBlock.name = "forward";
172+
const block2 = new Block(mockProtoBlock, mockBlocks);
173+
expect(block2.isInlineCollapsible()).toBe(false);
174+
});
175+
156176
it("hasCapability() should read protoblock capability metadata", () => {
157177
mockProtoBlock.capabilities.collapsible = true;
158178
mockProtoBlock.capabilities.specialInput = true;

js/protoblocks.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,9 +1717,6 @@ class BaseBlock extends ProtoBlock {
17171717
}
17181718

17191719
this.setCapabilities(this._style.capabilities);
1720-
if (this._style.canCollapse) {
1721-
this.setCapability("collapsible", true);
1722-
}
17231720

17241721
this.staticLabels = [this._style.name || ""];
17251722
this.dockTypes = [];

0 commit comments

Comments
 (0)