mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-18 09:21:04 -04:00
Add tests that serializing a costume does not save any data for assets that were missing when the project was first loaded
This commit is contained in:
parent
8cf390d2b5
commit
8b9ce99762
2 changed files with 18 additions and 0 deletions
test/integration
|
@ -12,6 +12,7 @@ const makeTestStorage = require('../fixtures/make-test-storage');
|
|||
const FakeRenderer = require('../fixtures/fake-renderer');
|
||||
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
|
||||
const VirtualMachine = require('../../src/index');
|
||||
const {serializeCostumes} = require('../../src/serialization/serialize-assets');
|
||||
|
||||
const projectUri = path.resolve(__dirname, '../fixtures/missing_svg.sb3');
|
||||
const project = readFileToBuffer(projectUri);
|
||||
|
@ -82,6 +83,15 @@ test('load and then save sb3 project with missing costume file', t => {
|
|||
// Test that we didn't save any data about the costume being broken
|
||||
t.notOk(missingCostume.broken);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime);
|
||||
t.equal(costumeDescs.length, 1); // Should only have one costume, the backdrop
|
||||
|
||||
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.svg`);
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@ const makeTestStorage = require('../fixtures/make-test-storage');
|
|||
const FakeRenderer = require('../fixtures/fake-renderer');
|
||||
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
|
||||
const VirtualMachine = require('../../src/index');
|
||||
const {serializeCostumes} = require('../../src/serialization/serialize-assets');
|
||||
|
||||
// The particular project that we're loading doesn't matter for this test
|
||||
const projectUri = path.resolve(__dirname, '../fixtures/default.sb3');
|
||||
|
@ -80,6 +81,13 @@ test('load and then save sprite3 with missing vector costume file', t => {
|
|||
// Test that we didn't save any data about the costume being broken
|
||||
t.notOk(missingCostume.broken);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('serializeCostume does not save data for missing costume', t => {
|
||||
const costumeDescs = serializeCostumes(vm.runtime, vm.runtime.targets[2].id);
|
||||
t.equal(costumeDescs.length, 0);
|
||||
|
||||
t.end();
|
||||
process.nextTick(process.exit);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue