scratch-vm/test/integration/motion.js

35 lines
919 B
JavaScript
Raw Normal View History

var test = require('tap').test;
2016-12-23 21:08:13 -05:00
var extract = require('../fixtures/extract');
var VirtualMachine = require('../../src/index');
2016-12-23 21:08:13 -05:00
var path = __dirname + '/../fixtures/motion.sb2';
var project = extract(path);
2016-12-23 21:08:13 -05:00
test('motion project', function (t) {
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);
2016-12-23 21:08:13 -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
t.doesNotThrow(function () {
vm.start();
vm.clear();
2016-12-23 14:09:35 -05:00
vm.setCompatibilityMode(false);
vm.setTurboMode(false);
2016-12-23 21:08:13 -05:00
vm.loadProject(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);
});