feat(utils/testing): introduce async/await for actions in tests

This commit is contained in:
Pascal Precht 2020-03-05 14:45:37 +01:00 committed by Pascal Precht
parent ec134b9307
commit 0e32cc09b5
1 changed files with 9 additions and 3 deletions

View File

@ -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) {