mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
Add test for renamed local lists
This commit is contained in:
parent
2acb39932a
commit
53429f0917
2 changed files with 14 additions and 8 deletions
BIN
test/fixtures/list-monitor-rename.sb3
vendored
BIN
test/fixtures/list-monitor-rename.sb3
vendored
Binary file not shown.
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue