mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-08 20:14:00 -04:00
Add runtime event for when the project is loaded (#1669)
This commit is contained in:
parent
fd5e178d3b
commit
6ef600dc2c
3 changed files with 35 additions and 0 deletions
test/unit
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue