Add test for renamed local lists

This commit is contained in:
adroitwhiz 2020-03-12 17:00:58 -04:00
parent 2acb39932a
commit 53429f0917
2 changed files with 14 additions and 8 deletions

Binary file not shown.

View file

@ -14,16 +14,22 @@ test('importing sb3 project with incorrect list monitor name', t => {
// Evaluate playground data and exit // Evaluate playground data and exit
vm.on('playgroundData', () => { vm.on('playgroundData', () => {
const stage = vm.runtime.targets[0]; const stage = vm.runtime.targets[0];
const cat = vm.runtime.targets[1];
// Global list named "renamed" exists for (const {target, renamedListName} of [
const variableId = Object.keys(stage.variables).find(k => stage.variables[k].name === 'renamed'); {target: stage, renamedListName: 'renamed global'},
const monitorRecord = vm.runtime._monitorState.get(variableId); {target: cat, renamedListName: 'renamed local'}
const monitorBlock = vm.runtime.monitorBlocks.getBlock(variableId); ]) {
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'); t.equal(monitorRecord.opcode, 'data_listcontents');
// The list name should be properly set to "renamed" // The list name should be properly renamed
t.equal(monitorRecord.params.LIST, 'renamed'); t.equal(monitorRecord.params.LIST, renamedListName);
t.equal(monitorBlock.fields.LIST.value, 'renamed'); t.equal(monitorBlock.fields.LIST.value, renamedListName);
}
t.end(); t.end();
process.nextTick(process.exit); process.nextTick(process.exit);