Add two menu types to the internal-extension test.

This commit is contained in:
picklesrus 2018-01-31 17:20:19 -08:00
parent b6bb92d8f6
commit 57d3e564e2

View file

@ -22,13 +22,27 @@ class TestInternalExtension {
{
opcode: 'go'
}
]
],
menus: {
simpleMenu: this._buildAMenu(),
dynamicMenu: '_buildDynamicMenu',
}
};
}
go () {
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 => {
@ -47,5 +61,14 @@ test('internal extension', t => {
t.notOk(extension.status.goCalled);
func();
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');
});
});