scratch-vm/test/unit/serialization_sb3.js

27 lines
805 B
JavaScript
Raw Normal View History

2017-04-26 16:50:53 -04:00
const test = require('tap').test;
2018-04-04 18:24:35 -04:00
const path = require('path');
2017-04-26 16:50:53 -04:00
const VirtualMachine = require('../../src/index');
const sb3 = require('../../src/serialization/sb3');
2018-04-04 18:24:35 -04:00
const extract = require('../fixtures/extract');
const projectPath = path.resolve(__dirname, '../fixtures/clone-cleanup.sb2');
2016-12-30 10:19:58 -05:00
2017-04-26 16:50:53 -04:00
test('serialize', t => {
const vm = new VirtualMachine();
2018-04-04 18:24:35 -04:00
vm.loadProject(extract(projectPath))
2018-03-16 11:43:27 -04:00
.then(() => {
const result = sb3.serialize(vm.runtime);
// @todo Analyze
t.type(JSON.stringify(result), 'string');
t.end();
});
2016-12-30 10:19:58 -05:00
});
2017-04-26 16:50:53 -04:00
test('deserialize', t => {
const vm = new VirtualMachine();
2017-11-03 14:42:20 -04:00
sb3.deserialize('', vm.runtime).then(({targets}) => {
// @todo Analyze
2017-04-27 17:49:57 -04:00
t.type(targets, 'object');
t.end();
});
2016-12-30 10:19:58 -05:00
});