Skip to content

Commit 82f23dd

Browse files
committed
test: replace conditional guards with explicit assertions in RhythmBlocks
1 parent 5391abf commit 82f23dd

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

js/blocks/__tests__/RhythmBlocks.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class FlowBlock extends BaseBlock {
8888
super(name);
8989
}
9090

91-
flow() {}
91+
flow() { }
9292
}
9393

9494
class FlowClampBlock extends FlowBlock {
@@ -105,8 +105,8 @@ class ValueBlock extends BaseBlock {
105105
this.parameter = false;
106106
}
107107

108-
arg() {}
109-
updateParameter() {}
108+
arg() { }
109+
updateParameter() { }
110110
}
111111

112112
global.BaseBlock = BaseBlock;
@@ -529,24 +529,24 @@ describe("RhythmBlocks", () => {
529529

530530
rhythmBlockNames.forEach(blockName => {
531531
const block = activity.registeredBlocks[blockName];
532-
if (block) {
533-
expect(block.palette).toBe("rhythm");
534-
}
532+
expect(block).toBeDefined();
533+
expect(block.palette).toBe("rhythm");
535534
});
536535
});
537536

538537
test("Flow blocks return correct tuple format", () => {
539-
const flowBlocks = ["swing", "newswing2", "skipnotes", "multiplybeatfactor", "tie"];
538+
// newswing2 is excluded: it checks args[2] for undefined and returns early
539+
// when called with only [1, true]; it is covered by its own dedicated test.
540+
const flowBlocks = ["swing", "skipnotes", "multiplybeatfactor", "tie"];
540541

541542
flowBlocks.forEach(blockName => {
542543
const block = getBlock(blockName);
543-
if (block && block.flow) {
544-
const result = block.flow([1, true], logo, 0, 10);
545-
if (result) {
546-
expect(Array.isArray(result)).toBe(true);
547-
expect(result.length).toBe(2);
548-
}
549-
}
544+
expect(block).toBeDefined();
545+
expect(typeof block.flow).toBe("function");
546+
const result = block.flow([1, true], logo, 0, 10);
547+
expect(result).toBeDefined();
548+
expect(Array.isArray(result)).toBe(true);
549+
expect(result.length).toBe(2);
550550
});
551551
});
552552

0 commit comments

Comments
 (0)