|
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/event.sb2'); |
|
const project = readFileToBuffer(uri); |
|
|
|
test('event', t => { |
|
const vm = new VirtualMachine(); |
|
vm.attachStorage(makeTestStorage()); |
|
|
|
|
|
vm.on('playgroundData', e => { |
|
const threads = JSON.parse(e.threads); |
|
t.ok(threads.length > 0); |
|
t.end(); |
|
process.nextTick(process.exit); |
|
}); |
|
|
|
|
|
t.doesNotThrow(() => { |
|
vm.start(); |
|
vm.clear(); |
|
vm.setCompatibilityMode(false); |
|
vm.setTurboMode(false); |
|
vm.loadProject(project).then(() => { |
|
vm.greenFlag(); |
|
|
|
|
|
setTimeout(() => { |
|
vm.getPlaygroundData(); |
|
vm.stopAll(); |
|
}, 2000); |
|
}); |
|
}); |
|
}); |
|
|