Spaces:
Restarting
Restarting
File size: 1,889 Bytes
30c32c8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
const path = require('path');
const test = require('tap').test;
const makeTestStorage = require('../fixtures/make-test-storage');
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
const VirtualMachine = require('../../src/index');
const projectUri = path.resolve(__dirname, '../fixtures/list-monitor-rename.sb3');
const project = readFileToBuffer(projectUri);
test('importing sb3 project with incorrect list monitor name', t => {
const vm = new VirtualMachine();
vm.attachStorage(makeTestStorage());
// Evaluate playground data and exit
vm.on('playgroundData', () => {
const stage = vm.runtime.targets[0];
const cat = vm.runtime.targets[1];
for (const {target, renamedListName} of [
{target: stage, renamedListName: 'renamed global'},
{target: cat, renamedListName: 'renamed local'}
]) {
const listId = Object.keys(target.variables).find(k => target.variables[k].name === renamedListName);
const monitorRecord = vm.runtime._monitorState.get(listId);
const monitorBlock = vm.runtime.monitorBlocks.getBlock(listId);
t.equal(monitorRecord.opcode, 'data_listcontents');
// The list name should be properly renamed
t.equal(monitorRecord.params.LIST, renamedListName);
t.equal(monitorBlock.fields.LIST.value, renamedListName);
}
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run
t.doesNotThrow(() => {
vm.start();
vm.clear();
vm.setCompatibilityMode(false);
vm.setTurboMode(false);
vm.loadProject(project).then(() => {
vm.greenFlag();
setTimeout(() => {
vm.getPlaygroundData();
vm.stopAll();
}, 100);
});
});
});
|