mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-10 15:02:06 -05:00
Add a button to the CoreEx extension
This commit is contained in:
parent
9eef05a7c5
commit
87a88e2caf
2 changed files with 13 additions and 5 deletions
|
@ -22,6 +22,11 @@ class Scratch3CoreExample {
|
||||||
id: 'coreExample',
|
id: 'coreExample',
|
||||||
name: 'CoreEx', // This string does not need to be translated as this extension is only used as an example.
|
name: 'CoreEx', // This string does not need to be translated as this extension is only used as an example.
|
||||||
blocks: [
|
blocks: [
|
||||||
|
{
|
||||||
|
func: 'MAKE_A_VARIABLE',
|
||||||
|
blockType: BlockType.BUTTON,
|
||||||
|
text: 'make a variable (CoreEx)'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
opcode: 'exampleOpcode',
|
opcode: 'exampleOpcode',
|
||||||
blockType: BlockType.REPORTER,
|
blockType: BlockType.REPORTER,
|
||||||
|
|
|
@ -83,13 +83,16 @@ test('load sync', t => {
|
||||||
t.ok(vm.extensionManager.isExtensionLoaded('coreExample'));
|
t.ok(vm.extensionManager.isExtensionLoaded('coreExample'));
|
||||||
|
|
||||||
t.equal(vm.runtime._blockInfo.length, 1);
|
t.equal(vm.runtime._blockInfo.length, 1);
|
||||||
t.equal(vm.runtime._blockInfo[0].blocks.length, 1);
|
t.equal(vm.runtime._blockInfo[0].blocks.length, 2);
|
||||||
t.type(vm.runtime._blockInfo[0].blocks[0].info, 'object');
|
t.type(vm.runtime._blockInfo[0].blocks[0].info, 'object');
|
||||||
t.equal(vm.runtime._blockInfo[0].blocks[0].info.opcode, 'exampleOpcode');
|
t.type(vm.runtime._blockInfo[0].blocks[0].info.func, 'MAKE_A_VARIABLE');
|
||||||
t.equal(vm.runtime._blockInfo[0].blocks[0].info.blockType, 'reporter');
|
t.equal(vm.runtime._blockInfo[0].blocks[0].info.blockType, 'button');
|
||||||
|
t.type(vm.runtime._blockInfo[0].blocks[1].info, 'object');
|
||||||
|
t.equal(vm.runtime._blockInfo[0].blocks[1].info.opcode, 'exampleOpcode');
|
||||||
|
t.equal(vm.runtime._blockInfo[0].blocks[1].info.blockType, 'reporter');
|
||||||
|
|
||||||
// Test the opcode function
|
// Test the opcode function
|
||||||
t.equal(vm.runtime._blockInfo[0].blocks[0].info.func(), 'no stage yet');
|
t.equal(vm.runtime._blockInfo[0].blocks[1].info.func(), 'no stage yet');
|
||||||
|
|
||||||
const sprite = new Sprite(null, vm.runtime);
|
const sprite = new Sprite(null, vm.runtime);
|
||||||
sprite.name = 'Stage';
|
sprite.name = 'Stage';
|
||||||
|
@ -97,7 +100,7 @@ test('load sync', t => {
|
||||||
stage.isStage = true;
|
stage.isStage = true;
|
||||||
vm.runtime.targets = [stage];
|
vm.runtime.targets = [stage];
|
||||||
|
|
||||||
t.equal(vm.runtime._blockInfo[0].blocks[0].info.func(), 'Stage');
|
t.equal(vm.runtime._blockInfo[0].blocks[1].info.func(), 'Stage');
|
||||||
|
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue