Fix typo uncovered by loading lonely variable reporters

This commit is contained in:
Paul Kaplan 2018-12-05 16:59:47 -05:00
parent be65b615a2
commit 809d2de9f2
2 changed files with 8 additions and 3 deletions
src/serialization
test/unit

View file

@ -802,7 +802,7 @@ const deserializeBlocks = function (blocks) {
// this is one of the primitives
// delete the old entry in object.blocks and replace it w/the
// deserialized object
delete block[blockId];
delete blocks[blockId];
deserializeInputDesc(block, null, false, blocks);
continue;
}

View file

@ -243,10 +243,15 @@ test('(#1608) serializeBlocks maintains top level variable reporters', t => {
vm.loadProject(readFileToBuffer(variableReporterSB2ProjectPath))
.then(() => {
const blocks = vm.runtime.targets[0].blocks._blocks;
const result = sb3.serialize(vm.runtime).targets[0].blocks;
const result = sb3.serialize(vm.runtime);
// Project should have 1 block, a top-level variable reporter
t.equal(Object.keys(blocks).length, 1);
t.equal(Object.keys(result).length, 1);
t.equal(Object.keys(result.targets[0].blocks).length, 1);
// Make sure deserializing these blocks works
t.doesNotThrow(() => {
sb3.deserialize(JSON.parse(JSON.stringify(result)), vm.runtime);
});
t.end();
});
});