scratch-vm/test/integration/looks.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

const path = require('path');
const test = require('tap').test;
const makeTestStorage = require('../fixtures/make-test-storage');
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
const VirtualMachine = require('../../src/index');
const uri = path.resolve(__dirname, '../fixtures/looks.sb2');
const project = readFileToBuffer(uri);
test('looks', t => {
const vm = new VirtualMachine();
vm.attachStorage(makeTestStorage());
2016-12-23 14:09:35 -05:00
// Evaluate playground data and exit
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
2016-12-23 21:08:13 -05:00
t.ok(threads.length === 0);
vm.quit();
2016-12-23 14:09:35 -05:00
t.end();
});
// Start VM, load project, and run
t.doesNotThrow(() => {
vm.start();
vm.clear();
2016-12-23 14:09:35 -05:00
vm.setCompatibilityMode(false);
vm.setTurboMode(false);
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
setTimeout(() => {
2017-04-18 11:55:38 -04:00
vm.getPlaygroundData();
vm.stopAll();
}, 2000);
});
});
});