Skip to content

Commit

Permalink
feat(utils/testing): introduce async/await for actions in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0x-r4bbit committed Mar 24, 2020
1 parent ec134b9 commit 0e32cc0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/utils/testing/src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ class Events {
this.handlers[ev].push(sinon.spy(cb));
}

emit(ev, ...args) {

async emit(ev, ...args) {
this.emissions[ev] = args;
return this.trigger(ev);
}

once(name, cb) {
cb();
}

async trigger(ev, ...args) {
if (!this.handlers[ev]) {
return;
}

this.handlers[ev].forEach(h => h(...args));
await Promise.all(this.handlers[ev].map(async h => h(args)));
}

request(cmd, ...args) {
Expand Down

0 comments on commit 0e32cc0

Please sign in to comment.