Skip to content

Commit

Permalink
Modify saveProjectSb3DontZip asset order to match saveProjectSb3
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Aug 1, 2023
1 parent 4631dfc commit a1d2cd1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/virtual-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class VirtualMachine extends EventEmitter {
const files = {
'project.json': new _TextEncoder().encode(projectJson)
};
for (const fileDesc of soundDescs.concat(costumeDescs)) {
for (const fileDesc of costumeDescs.concat(soundDescs)) {
files[fileDesc.fileName] = fileDesc.fileContent;
}

Expand Down
23 changes: 23 additions & 0 deletions test/integration/tw_serialize_asset_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,26 @@ test('exportSprite serialization order', t => {
});
});
});

test('saveProjectSb3DontZip', t => {
t.plan(13);
const vm = new VM();
vm.attachStorage(makeTestStorage());
vm.loadProject(fixture).then(() => {
const exported = vm.saveProjectSb3DontZip();
const files = Object.keys(exported);

for (let i = 0; i < files.length; i++) {
// 6 costumes, 6 sounds
if (i === 0) {
t.equal(files[i], 'project.json', 'first file is project.json');
} else if (i < 7) {
t.ok(files[i].endsWith('.svg'), `file ${i + 1} is costume`);
} else {
t.ok(files[i].endsWith('.wav'), `file ${i + 1} is sound`);
}
}

t.end();
});
});

0 comments on commit a1d2cd1

Please sign in to comment.