2016-12-23 10:39:19 -05:00
|
|
|
var test = require('tap').test;
|
|
|
|
var VirtualMachine = require('../../src/index');
|
|
|
|
|
|
|
|
var project = require('../fixtures/project_default.json');
|
|
|
|
|
2016-12-23 14:09:35 -05:00
|
|
|
test('default project', function (t) {
|
2016-12-23 10:39:19 -05:00
|
|
|
var vm = new VirtualMachine();
|
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
|
2016-12-23 10:39:19 -05:00
|
|
|
t.doesNotThrow(function () {
|
|
|
|
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);
|
|
|
|
vm.loadProject(JSON.stringify(project));
|
|
|
|
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);
|
2016-12-23 10:39:19 -05:00
|
|
|
});
|