Skip to content

Commit 0e32cc0

Browse files
committed
feat(utils/testing): introduce async/await for actions in tests
1 parent ec134b9 commit 0e32cc0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/utils/testing/src/events.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,21 @@ class Events {
2222
this.handlers[ev].push(sinon.spy(cb));
2323
}
2424

25-
emit(ev, ...args) {
26-
25+
async emit(ev, ...args) {
2726
this.emissions[ev] = args;
27+
return this.trigger(ev);
28+
}
29+
30+
once(name, cb) {
31+
cb();
32+
}
2833

34+
async trigger(ev, ...args) {
2935
if (!this.handlers[ev]) {
3036
return;
3137
}
3238

33-
this.handlers[ev].forEach(h => h(...args));
39+
await Promise.all(this.handlers[ev].map(async h => h(args)));
3440
}
3541

3642
request(cmd, ...args) {

0 commit comments

Comments
 (0)