scratch-vm/test/integration/data.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

const path = require('path');
const test = require('tap').test;
const makeTestStorage = require('../fixtures/make-test-storage');
const extract = require('../fixtures/extract');
const VirtualMachine = require('../../src/index');
2016-12-23 14:09:35 -05:00
const uri = path.resolve(__dirname, '../fixtures/data.sb2');
const project = extract(uri);
2016-12-23 14:09:35 -05:00
// TODO (#828) Need to re-activate this test after sb2 import works for broadcast
// blocks
test('data', {todo: true}, t => {
const vm = new VirtualMachine();
vm.attachStorage(makeTestStorage());
2016-12-23 14:09:35 -05:00
// Evaluate playground data and exit
vm.on('playgroundData', () => {
2016-12-23 21:08:13 -05:00
// @todo Additional tests
2016-12-23 14:09:35 -05:00
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run
t.doesNotThrow(() => {
2016-12-23 14:09:35 -05:00
vm.start();
vm.clear();
vm.setCompatibilityMode(false);
vm.setTurboMode(false);
vm.loadProject(project).then(() => {
2017-04-18 11:55:38 -04:00
vm.greenFlag();
2016-12-23 14:09:35 -05:00
2017-04-18 11:55:38 -04:00
// After two seconds, get playground data and stop
setTimeout(() => {
2017-04-18 11:55:38 -04:00
vm.getPlaygroundData();
vm.stopAll();
}, 2000);
});
});
2016-12-23 14:09:35 -05:00
});