2017-04-20 19:17:05 -04:00
|
|
|
const path = require('path');
|
|
|
|
const test = require('tap').test;
|
2017-06-09 17:54:10 -04:00
|
|
|
const makeTestStorage = require('../fixtures/make-test-storage');
|
2017-04-20 19:17:05 -04:00
|
|
|
const extract = require('../fixtures/extract');
|
|
|
|
const VirtualMachine = require('../../src/index');
|
2016-12-23 10:39:19 -05:00
|
|
|
|
2017-04-20 19:17:05 -04:00
|
|
|
const uri = path.resolve(__dirname, '../fixtures/motion.sb2');
|
|
|
|
const project = extract(uri);
|
2016-12-23 10:39:19 -05:00
|
|
|
|
2017-11-29 10:43:07 -05:00
|
|
|
// TODO (#828) Need to re-activate this test after sb2 import works for broadcast
|
|
|
|
// blocks
|
|
|
|
test('motion', {todo: true}, t => {
|
2017-04-20 19:17:05 -04:00
|
|
|
const vm = new VirtualMachine();
|
2017-06-09 17:54:10 -04:00
|
|
|
vm.attachStorage(makeTestStorage());
|
2016-12-23 14:09:35 -05:00
|
|
|
|
|
|
|
// Evaluate playground data and exit
|
2017-04-20 19:17:05 -04:00
|
|
|
vm.on('playgroundData', e => {
|
|
|
|
const threads = JSON.parse(e.threads);
|
2017-01-05 16:58:31 -05:00
|
|
|
t.ok(threads.length > 0);
|
2016-12-23 14:09:35 -05:00
|
|
|
t.end();
|
|
|
|
process.nextTick(process.exit);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Start VM, load project, and run
|
2017-04-20 19:17:05 -04:00
|
|
|
t.doesNotThrow(() => {
|
2016-12-23 10:39:19 -05:00
|
|
|
vm.start();
|
|
|
|
vm.clear();
|
2016-12-23 14:09:35 -05:00
|
|
|
vm.setCompatibilityMode(false);
|
2016-12-23 10:39:19 -05:00
|
|
|
vm.setTurboMode(false);
|
2017-04-20 19:17:05 -04:00
|
|
|
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
|
2017-04-20 19:17:05 -04:00
|
|
|
setTimeout(() => {
|
2017-04-18 11:55:38 -04:00
|
|
|
vm.getPlaygroundData();
|
|
|
|
vm.stopAll();
|
|
|
|
}, 2000);
|
|
|
|
});
|
|
|
|
});
|
2016-12-23 10:39:19 -05:00
|
|
|
});
|