From a1d2cd108afa45a3f59f46a84cb0682f6628eb17 Mon Sep 17 00:00:00 2001 From: Muffin Date: Mon, 31 Jul 2023 22:37:16 -0500 Subject: [PATCH] Modify saveProjectSb3DontZip asset order to match saveProjectSb3 --- src/virtual-machine.js | 2 +- test/integration/tw_serialize_asset_order.js | 23 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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(); + }); +});