mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -05:00
Add a unit test to ensure extensions are loaded on shareBlocksToTarget
This commit is contained in:
parent
c8ad1955d4
commit
979ed66594
1 changed files with 29 additions and 0 deletions
|
@ -910,6 +910,35 @@ test('shareBlocksToTarget chooses a fresh name for a new global variable checkin
|
|||
});
|
||||
});
|
||||
|
||||
test('shareBlocksToTarget loads extensions that have not yet been loaded', t => {
|
||||
const vm = new VirtualMachine();
|
||||
const runtime = vm.runtime;
|
||||
const spr1 = new Sprite(null, runtime);
|
||||
const stage = spr1.createClone();
|
||||
runtime.targets = [stage];
|
||||
|
||||
const fakeBlocks = [
|
||||
{opcode: 'loaded_fakeblock'},
|
||||
{opcode: 'notloaded_fakeblock'}
|
||||
];
|
||||
|
||||
// Stub the extension manager
|
||||
const loadedIds = [];
|
||||
vm.extensionManager = {
|
||||
isExtensionLoaded: id => id === 'loaded',
|
||||
loadExtensionURL: id => new Promise(resolve => {
|
||||
loadedIds.push(id);
|
||||
resolve();
|
||||
})
|
||||
};
|
||||
|
||||
vm.shareBlocksToTarget(fakeBlocks, stage.id).then(() => {
|
||||
// Verify that only the not-loaded extension gets loaded
|
||||
t.deepEqual(loadedIds, ['notloaded']);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('Setting turbo mode emits events', t => {
|
||||
let turboMode = null;
|
||||
|
||||
|
|
Loading…
Reference in a new issue