mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -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);
|
]) {
|
||||||
t.equal(monitorRecord.opcode, 'data_listcontents');
|
const listId = Object.keys(target.variables).find(k => target.variables[k].name === renamedListName);
|
||||||
|
|
||||||
// The list name should be properly set to "renamed"
|
const monitorRecord = vm.runtime._monitorState.get(listId);
|
||||||
t.equal(monitorRecord.params.LIST, 'renamed');
|
const monitorBlock = vm.runtime.monitorBlocks.getBlock(listId);
|
||||||
t.equal(monitorBlock.fields.LIST.value, 'renamed');
|
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();
|
t.end();
|
||||||
process.nextTick(process.exit);
|
process.nextTick(process.exit);
|
||||||
|
|
Loading…
Reference in a new issue