Merge pull request #1825 from paulkaplan/emit-start-publicly

Emit PROJECT_START event publicly on green flag click.
This commit is contained in:
Paul Kaplan 2018-12-06 15:38:05 -05:00 committed by GitHub
commit 8405ff00d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -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);
});

View file

@ -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;