diff --git a/src/virtual-machine.js b/src/virtual-machine.js index f292ad6b..dea8d65f 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -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; } diff --git a/test/integration/tw_serialize_asset_order.js b/test/integration/tw_serialize_asset_order.js index def43dc5..f8d9a3bb 100644 --- a/test/integration/tw_serialize_asset_order.js +++ b/test/integration/tw_serialize_asset_order.js @@ -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(); + }); +});