mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
Add two menu types to the internal-extension test.
This commit is contained in:
parent
b6bb92d8f6
commit
57d3e564e2
1 changed files with 24 additions and 1 deletions
|
@ -22,13 +22,27 @@ class TestInternalExtension {
|
||||||
{
|
{
|
||||||
opcode: 'go'
|
opcode: 'go'
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
menus: {
|
||||||
|
simpleMenu: this._buildAMenu(),
|
||||||
|
dynamicMenu: '_buildDynamicMenu',
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
go () {
|
go () {
|
||||||
this.status.goCalled = true;
|
this.status.goCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_buildAMenu() {
|
||||||
|
this.status.buildMenuCalled = true;
|
||||||
|
return ['abcd', 'efgh', 'ijkl'];
|
||||||
|
}
|
||||||
|
|
||||||
|
_buildDynamicMenu() {
|
||||||
|
this.status.buildDynamicMenuCalled = true;
|
||||||
|
return [1, 2, 3, 4, 6];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test('internal extension', t => {
|
test('internal extension', t => {
|
||||||
|
@ -47,5 +61,14 @@ test('internal extension', t => {
|
||||||
t.notOk(extension.status.goCalled);
|
t.notOk(extension.status.goCalled);
|
||||||
func();
|
func();
|
||||||
t.ok(extension.status.goCalled);
|
t.ok(extension.status.goCalled);
|
||||||
|
|
||||||
|
// There should be 2 menus - one is an array, one is the function to call.
|
||||||
|
t.equal(vm.runtime._blockInfo[0].menus.length, 2);
|
||||||
|
// First menu has 3 items.
|
||||||
|
t.equal(
|
||||||
|
vm.runtime._blockInfo[0].menus[0].json.args0[0].options.length, 3);
|
||||||
|
// Second menu is a dynamic menu and therefore should be a function.
|
||||||
|
t.type(
|
||||||
|
vm.runtime._blockInfo[0].menus[1].json.args0[0].options, 'function');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue