mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-05 01:54:52 -04:00
re-emit the PROJECT_START event publicly, add unit test
This commit is contained in:
parent
23d9c21a0e
commit
56c062eee3
2 changed files with 14 additions and 0 deletions
|
@ -78,6 +78,9 @@ class VirtualMachine extends EventEmitter {
|
|||
this.runtime.on(Runtime.BLOCK_GLOW_OFF, glowData => {
|
||||
this.emit(Runtime.BLOCK_GLOW_OFF, glowData);
|
||||
});
|
||||
this.runtime.on(Runtime.PROJECT_START, () => {
|
||||
this.emit(Runtime.PROJECT_START);
|
||||
});
|
||||
this.runtime.on(Runtime.PROJECT_RUN_START, () => {
|
||||
this.emit(Runtime.PROJECT_RUN_START);
|
||||
});
|
||||
|
|
|
@ -983,6 +983,17 @@ test('Starting the VM emits an event', t => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('vm.greenFlag() emits a PROJECT_START event', t => {
|
||||
let greenFlagged = false;
|
||||
const vm = new VirtualMachine();
|
||||
vm.addListener('PROJECT_START', () => {
|
||||
greenFlagged = true;
|
||||
});
|
||||
vm.greenFlag();
|
||||
t.equal(greenFlagged, true);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('toJSON encodes Infinity/NaN as 0, not null', t => {
|
||||
const vm = new VirtualMachine();
|
||||
const runtime = vm.runtime;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue