mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-03-13 17:04:39 -04:00
Merge pull request #1825 from paulkaplan/emit-start-publicly
Emit PROJECT_START event publicly on green flag click.
This commit is contained in:
commit
8405ff00d4
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);
|
||||
});
|
||||
|
|
|
@ -1013,6 +1013,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…
Reference in a new issue