Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/check instance on wait for event #49

Merged
merged 10 commits into from Mar 6, 2024
10 changes: 7 additions & 3 deletions packages/runtime/test/lib/MockEventBus.ts
Expand Up @@ -25,9 +25,13 @@ export class MockEventBus extends EventEmitter2EventBus {
subscriptionTarget: SubscriptionTarget<TEvent> & { namespace: string },
predicate?: (event: TEvent) => boolean
): Promise<TEvent> {
const alreadyTriggeredEvents = this.publishedEvents.find((e) => e.namespace === subscriptionTarget.namespace && (!predicate || predicate(e as TEvent))) as
| TEvent
| undefined;
const alreadyTriggeredEvents = this.publishedEvents.find((e) => {
return (
jkoenig134 marked this conversation as resolved.
Show resolved Hide resolved
e.namespace === subscriptionTarget.namespace &&
(typeof subscriptionTarget === "string" || e instanceof (subscriptionTarget as any)) &&
jkoenig134 marked this conversation as resolved.
Show resolved Hide resolved
(!predicate || predicate(e as TEvent))
);
}) as TEvent | undefined;
if (alreadyTriggeredEvents) {
return alreadyTriggeredEvents;
}
Expand Down