Add a unit test to ensure extensions are loaded on shareBlocksToTarget

This commit is contained in:
Paul Kaplan 2018-11-05 13:01:00 -05:00
parent c8ad1955d4
commit 979ed66594

View file

@ -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;