Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Dec 22, 2023
1 parent ef9466a commit 8b25fb9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/unit/tw_branch_icon_uri.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const {test} = require('tap');
const VirtualMachine = require('../../src/virtual-machine');
const BlockType = require('../../src/extension-support/block-type');

test('branchIconURI', t => {
const vm = new VirtualMachine();
vm.extensionManager._registerInternalExtension({
getInfo: () => ({
id: 'testextension',
name: 'test',
blocks: [
{
blockType: BlockType.LOOP,
opcode: 'block1',
text: 'no custom icon'
},
{
blockType: BlockType.LOOP,
opcode: 'block2',
text: 'LOOP with custom icon',
branchIconURI: 'data:whatever1'
},
{
blockType: BlockType.CONDITIONAL,
opcode: 'block2',
text: 'CONDITIONAL with custom icon',
branchIconURI: 'data:whatever2'
}
]
})
});

const blocks = vm.runtime.getBlocksJSON();
t.equal(blocks[0].args2[0].src, './static/blocks-media/repeat.svg', 'default custom icon');
t.equal(blocks[1].args2[0].src, 'data:whatever1', 'LOOP with custom icon');
t.equal(blocks[2].args2[0].src, 'data:whatever2', 'CONDITIONAL with custom icon');

t.end();
});

0 comments on commit 8b25fb9

Please sign in to comment.