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');
|
2018-04-05 13:46:07 -04:00
|
|
|
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
|
2017-04-20 19:17:05 -04:00
|
|
|
const VirtualMachine = require('../../src/index');
|
2016-12-23 14:09:35 -05:00
|
|
|
|
2017-04-20 19:17:05 -04:00
|
|
|
const uri = path.resolve(__dirname, '../fixtures/data.sb2');
|
2018-04-05 13:46:07 -04:00
|
|
|
const project = readFileToBuffer(uri);
|
2016-12-23 14:09:35 -05:00
|
|
|
|
2017-04-20 19:17:05 -04:00
|
|
|
test('data', t => {
|
|
|
|
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', () => {
|
2016-12-23 21:08:13 -05:00
|
|
|
// @todo Additional tests
|
2022-06-06 15:00:10 -04:00
|
|
|
vm.quit();
|
2016-12-23 14:09:35 -05:00
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Start VM, load project, and run
|
2017-04-20 19:17:05 -04:00
|
|
|
t.doesNotThrow(() => {
|
2016-12-23 14:09:35 -05:00
|
|
|
vm.start();
|
|
|
|
vm.clear();
|
|
|
|
vm.setCompatibilityMode(false);
|
|
|
|
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 14:09:35 -05:00
|
|
|
});
|