2017-12-20 11:49:40 -05:00
|
|
|
const path = require('path');
|
2019-01-02 12:19:58 -05:00
|
|
|
const test = require('tap').skip;
|
2017-12-20 11:49:40 -05:00
|
|
|
const makeTestStorage = require('../fixtures/make-test-storage');
|
2018-04-05 13:46:07 -04:00
|
|
|
const extractProjectJson = require('../fixtures/readProjectFile').extractProjectJson;
|
2017-12-20 11:49:40 -05:00
|
|
|
const VirtualMachine = require('../../src/index');
|
|
|
|
|
|
|
|
const uri = path.resolve(__dirname, '../fixtures/default.sb2');
|
2018-04-05 13:58:45 -04:00
|
|
|
const project = extractProjectJson(uri);
|
2017-12-20 11:49:40 -05:00
|
|
|
|
|
|
|
test('default', t => {
|
|
|
|
const vm = new VirtualMachine();
|
|
|
|
vm.attachStorage(makeTestStorage());
|
|
|
|
|
|
|
|
// Evaluate playground data and exit
|
|
|
|
vm.on('playgroundData', e => {
|
|
|
|
const threads = JSON.parse(e.threads);
|
|
|
|
t.ok(threads.length === 0);
|
|
|
|
t.end();
|
|
|
|
process.nextTick(process.exit);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Start VM, load project, and run
|
|
|
|
t.doesNotThrow(() => {
|
|
|
|
vm.start();
|
|
|
|
vm.clear();
|
|
|
|
vm.setCompatibilityMode(false);
|
|
|
|
vm.setTurboMode(false);
|
|
|
|
vm.loadProject(project).then(() => {
|
|
|
|
vm.greenFlag();
|
|
|
|
|
|
|
|
// After two seconds, get playground data and stop
|
|
|
|
setTimeout(() => {
|
|
|
|
vm.getPlaygroundData();
|
|
|
|
vm.stopAll();
|
|
|
|
}, 2000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|