2016-12-23 21:31:00 -05:00
|
|
|
var path = require('path');
|
2016-12-23 14:09:35 -05:00
|
|
|
var test = require('tap').test;
|
2017-03-09 18:50:43 -05:00
|
|
|
var attachTestStorage = require('../fixtures/attach-test-storage');
|
2016-12-23 21:08:13 -05:00
|
|
|
var extract = require('../fixtures/extract');
|
2016-12-23 14:09:35 -05:00
|
|
|
var VirtualMachine = require('../../src/index');
|
|
|
|
|
2016-12-23 21:31:00 -05:00
|
|
|
var uri = path.resolve(__dirname, '../fixtures/control.sb2');
|
|
|
|
var project = extract(uri);
|
2016-12-23 14:09:35 -05:00
|
|
|
|
2017-01-05 16:58:31 -05:00
|
|
|
test('control', function (t) {
|
2016-12-23 14:09:35 -05:00
|
|
|
var vm = new VirtualMachine();
|
2017-03-09 18:50:43 -05:00
|
|
|
attachTestStorage(vm);
|
2016-12-23 14:09:35 -05:00
|
|
|
|
|
|
|
// Evaluate playground data and exit
|
|
|
|
vm.on('playgroundData', function (e) {
|
|
|
|
var threads = JSON.parse(e.threads);
|
|
|
|
t.ok(threads.length > 0);
|
|
|
|
t.end();
|
|
|
|
process.nextTick(process.exit);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Start VM, load project, and run
|
|
|
|
t.doesNotThrow(function () {
|
|
|
|
vm.start();
|
|
|
|
vm.clear();
|
|
|
|
vm.setCompatibilityMode(false);
|
|
|
|
vm.setTurboMode(false);
|
2017-04-18 11:55:38 -04:00
|
|
|
vm.loadProject(project).then(function () {
|
|
|
|
vm.greenFlag();
|
|
|
|
});
|
2016-12-23 14:09:35 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// After two seconds, get playground data and stop
|
|
|
|
setTimeout(function () {
|
|
|
|
vm.getPlaygroundData();
|
|
|
|
vm.stopAll();
|
|
|
|
}, 2000);
|
|
|
|
});
|