mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-03-13 17:04:39 -04:00
add test of deserializing origin
This commit is contained in:
parent
679efb28fd
commit
8483c1a467
3 changed files with 17 additions and 0 deletions
BIN
test/fixtures/origin-absent.sb3
vendored
Normal file
BIN
test/fixtures/origin-absent.sb3
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/origin.sb3
vendored
Normal file
BIN
test/fixtures/origin.sb3
vendored
Normal file
Binary file not shown.
|
@ -11,6 +11,8 @@ const commentsSB3NoDupeIds = path.resolve(__dirname, '../fixtures/comments_no_du
|
|||
const variableReporterSB2ProjectPath = path.resolve(__dirname, '../fixtures/top-level-variable-reporter.sb2');
|
||||
const topLevelReportersProjectPath = path.resolve(__dirname, '../fixtures/top-level-reporters.sb3');
|
||||
const draggableSB3ProjectPath = path.resolve(__dirname, '../fixtures/draggable.sb3');
|
||||
const originSB3ProjectPath = path.resolve(__dirname, '../fixtures/origin.sb3');
|
||||
const originAbsentSB3ProjectPath = path.resolve(__dirname, '../fixtures/origin-absent.sb3');
|
||||
const FakeRenderer = require('../fixtures/fake-renderer');
|
||||
|
||||
test('serialize', t => {
|
||||
|
@ -324,3 +326,18 @@ test('(#1850) sprite draggability state read when loading SB3 file', t => {
|
|||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('load origin value from SB3 file json metadata', t => {
|
||||
const vm = new VirtualMachine();
|
||||
vm.loadProject(readFileToBuffer(originSB3ProjectPath))
|
||||
.then(() => {
|
||||
t.type(vm.runtime.origin, 'string');
|
||||
})
|
||||
.then(() => vm.loadProject(readFileToBuffer(originAbsentSB3ProjectPath)))
|
||||
.then(() => {
|
||||
// After loading a project with an origin, then loading one without an origin,
|
||||
// origin value should no longer be set.
|
||||
t.equal(vm.runtime.origin, null);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue