From 87a88e2caf1a60dbec09e89e4d617601ce10ead8 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Tue, 2 Apr 2019 22:50:52 -0700 Subject: [PATCH] Add a button to the CoreEx extension --- src/blocks/scratch3_core_example.js | 5 +++++ test/integration/internal-extension.js | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/blocks/scratch3_core_example.js b/src/blocks/scratch3_core_example.js index 7781bf25a..501e569c4 100644 --- a/src/blocks/scratch3_core_example.js +++ b/src/blocks/scratch3_core_example.js @@ -22,6 +22,11 @@ class Scratch3CoreExample { id: 'coreExample', name: 'CoreEx', // This string does not need to be translated as this extension is only used as an example. blocks: [ + { + func: 'MAKE_A_VARIABLE', + blockType: BlockType.BUTTON, + text: 'make a variable (CoreEx)' + }, { opcode: 'exampleOpcode', blockType: BlockType.REPORTER, diff --git a/test/integration/internal-extension.js b/test/integration/internal-extension.js index 476981c05..73111396e 100644 --- a/test/integration/internal-extension.js +++ b/test/integration/internal-extension.js @@ -83,13 +83,16 @@ test('load sync', t => { t.ok(vm.extensionManager.isExtensionLoaded('coreExample')); 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.equal(vm.runtime._blockInfo[0].blocks[0].info.opcode, 'exampleOpcode'); - t.equal(vm.runtime._blockInfo[0].blocks[0].info.blockType, 'reporter'); + t.type(vm.runtime._blockInfo[0].blocks[0].info.func, 'MAKE_A_VARIABLE'); + 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 - 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); sprite.name = 'Stage'; @@ -97,7 +100,7 @@ test('load sync', t => { stage.isStage = true; 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(); });