scratch-vm/test/integration/hat-execution-order.js
Ray Schamp bafdf8d9f2 Use ES6 linting rules in the project root
Update all tests for `no-var` and `prefer-arrow-callback` (using `--fix`)
2017-04-24 15:37:58 -04:00

42 lines
1.2 KiB
JavaScript

const path = require('path');
const test = require('tap').test;
const attachTestStorage = require('../fixtures/attach-test-storage');
const extract = require('../fixtures/extract');
const VirtualMachine = require('../../src/index');
const projectUri = path.resolve(__dirname, '../fixtures/hat-execution-order.sb2');
const project = extract(projectUri);
test('complex', t => {
const vm = new VirtualMachine();
attachTestStorage(vm);
// Evaluate playground data and exit
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
const results = vm.runtime.targets[0].lists.results.contents;
t.deepEqual(results, ['3', '2', '1', 'stage']);
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);
});
});
});