mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-09 14:32:07 -05:00
Add unit test for extension button
This commit is contained in:
parent
bed54bae1f
commit
254edd48d5
1 changed files with 13 additions and 2 deletions
|
@ -12,6 +12,11 @@ const testExtensionInfo = {
|
||||||
id: 'test',
|
id: 'test',
|
||||||
name: 'fake test extension',
|
name: 'fake test extension',
|
||||||
blocks: [
|
blocks: [
|
||||||
|
{
|
||||||
|
func: 'CREATE_VARIABLE',
|
||||||
|
blockType: BlockType.BUTTON,
|
||||||
|
text: 'this is a button'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
opcode: 'reporter',
|
opcode: 'reporter',
|
||||||
blockType: BlockType.REPORTER,
|
blockType: BlockType.REPORTER,
|
||||||
|
@ -58,6 +63,11 @@ const testExtensionInfo = {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const testButton = function (t, button) {
|
||||||
|
t.same(button.json, null); // should be null or undefined
|
||||||
|
t.equal(button.xml, '<button text="this is a button" callbackKey="CREATE_VARIABLE"></button>');
|
||||||
|
};
|
||||||
|
|
||||||
const testReporter = function (t, reporter) {
|
const testReporter = function (t, reporter) {
|
||||||
t.equal(reporter.json.type, 'test_reporter');
|
t.equal(reporter.json.type, 'test_reporter');
|
||||||
t.equal(reporter.json.outputShape, ScratchBlocksConstants.OUTPUT_SHAPE_ROUND);
|
t.equal(reporter.json.outputShape, ScratchBlocksConstants.OUTPUT_SHAPE_ROUND);
|
||||||
|
@ -72,7 +82,7 @@ const testReporter = function (t, reporter) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const testSeparator = function (t, separator) {
|
const testSeparator = function (t, separator) {
|
||||||
t.equal(separator.json, null);
|
t.same(separator.json, null); // should be null or undefined
|
||||||
t.equal(separator.xml, '<sep gap="36"/>');
|
t.equal(separator.xml, '<sep gap="36"/>');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -154,8 +164,9 @@ test('registerExtensionPrimitives', t => {
|
||||||
t.equal(blocksInfo.length, testExtensionInfo.blocks.length);
|
t.equal(blocksInfo.length, testExtensionInfo.blocks.length);
|
||||||
|
|
||||||
// Note that this also implicitly tests that block order is preserved
|
// Note that this also implicitly tests that block order is preserved
|
||||||
const [reporter, separator, command, conditional, loop] = blocksInfo;
|
const [button, reporter, separator, command, conditional, loop] = blocksInfo;
|
||||||
|
|
||||||
|
testButton(t, button);
|
||||||
testReporter(t, reporter);
|
testReporter(t, reporter);
|
||||||
testSeparator(t, separator);
|
testSeparator(t, separator);
|
||||||
testCommand(t, command);
|
testCommand(t, command);
|
||||||
|
|
Loading…
Reference in a new issue