mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 23:42:23 -05:00
c6c1a63ff0
+ Solve code conflicts, and handle deserialization of 3.0 projects. # Conflicts: # src/index.js # test/unit/serialization_sb2.js
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
var path = require('path');
|
|
var test = require('tap').test;
|
|
var extract = require('../fixtures/extract');
|
|
|
|
var renderedTarget = require('../../src/sprites/rendered-target');
|
|
var runtime = require('../../src/engine/runtime');
|
|
var sb2 = require('../../src/serialization/sb2');
|
|
|
|
test('spec', function (t) {
|
|
t.type(sb2, 'object');
|
|
t.type(sb2.deserialize, 'function');
|
|
t.end();
|
|
});
|
|
|
|
test('default', function (t) {
|
|
// Get SB2 JSON (string)
|
|
var uri = path.resolve(__dirname, '../fixtures/default.sb2');
|
|
var file = extract(uri);
|
|
|
|
// Create runtime instance & load SB2 into it
|
|
var rt = new runtime();
|
|
sb2.deserialize(file, rt);
|
|
|
|
// Test
|
|
t.type(file, 'string');
|
|
t.type(rt, 'object');
|
|
t.type(rt.targets, 'object');
|
|
|
|
t.ok(rt.targets[0] instanceof renderedTarget);
|
|
t.type(rt.targets[0].id, 'string');
|
|
t.type(rt.targets[0].blocks, 'object');
|
|
t.type(rt.targets[0].variables, 'object');
|
|
t.type(rt.targets[0].lists, 'object');
|
|
|
|
t.equal(rt.targets[0].isOriginal, true);
|
|
t.equal(rt.targets[0].currentCostume, 0);
|
|
t.equal(rt.targets[0].isOriginal, true);
|
|
t.equal(rt.targets[0].isStage, true);
|
|
|
|
t.ok(rt.targets[1] instanceof renderedTarget);
|
|
t.type(rt.targets[1].id, 'string');
|
|
t.type(rt.targets[1].blocks, 'object');
|
|
t.type(rt.targets[1].variables, 'object');
|
|
t.type(rt.targets[1].lists, 'object');
|
|
|
|
t.equal(rt.targets[1].isOriginal, true);
|
|
t.equal(rt.targets[1].currentCostume, 0);
|
|
t.equal(rt.targets[1].isOriginal, true);
|
|
t.equal(rt.targets[1].isStage, false);
|
|
t.end();
|
|
});
|