Add runtime event for when the project is loaded ()

This commit is contained in:
Katie Broida 2018-10-30 15:26:22 -04:00 committed by GitHub
parent fd5e178d3b
commit 6ef600dc2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 0 deletions

View file

@ -1,4 +1,7 @@
const test = require('tap').test;
const path = require('path');
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
const VirtualMachine = require('../../src/virtual-machine');
const Runtime = require('../../src/engine/runtime');
const MonitorRecord = require('../../src/engine/monitor-record');
const {Map} = require('immutable');
@ -108,3 +111,19 @@ test('getLabelForOpcode', t => {
t.end();
});
test('Project loaded emits runtime event', t => {
const vm = new VirtualMachine();
const projectUri = path.resolve(__dirname, '../fixtures/default.sb2');
const project = readFileToBuffer(projectUri);
let projectLoaded = false;
vm.runtime.addListener('PROJECT_LOADED', () => {
projectLoaded = true;
});
vm.loadProject(project).then(() => {
t.equal(projectLoaded, true, 'Project load event emitted');
t.end();
});
});