Skip to content

Commit da727e8

Browse files
committed
fix broken test
1 parent 23c514d commit da727e8

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/execution/__tests__/subscribe-test.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ describe('Subscription Publish Phase', () => {
760760

761761
it('should not trigger when subscription is thrown', async () => {
762762
const pubsub = new SimplePubSub<Email>();
763-
const subscription = createSubscription(pubsub);
763+
const subscription = await createSubscription(pubsub);
764764
assert(isAsyncIterable(subscription));
765765

766766
let payload = subscription.next();
@@ -793,17 +793,23 @@ describe('Subscription Publish Phase', () => {
793793
},
794794
});
795795

796+
// Throw error
797+
// See: https://github.com/repeaterjs/repeater/issues/72#issuecomment-963426268
798+
const error = new Error('should not trigger when subscription is thrown');
799+
const caughtError = subscription.throw(error).catch((e) => e);
796800
payload = subscription.next();
797801

798-
// Throw error
799-
let caughtError;
800-
try {
801-
/* c8 ignore next 2 */
802-
await subscription.throw('ouch');
803-
} catch (e) {
804-
caughtError = e;
805-
}
806-
expect(caughtError).to.equal('ouch');
802+
// A new email arrives!
803+
expect(
804+
pubsub.emit({
805+
from: 'yuzhi@graphql.org',
806+
subject: 'Alright 2',
807+
message: 'Tests are good 2',
808+
unread: true,
809+
}),
810+
).to.equal(true);
811+
812+
expect(await caughtError).to.equal(error);
807813

808814
expect(await payload).to.deep.equal({
809815
done: true,

0 commit comments

Comments
 (0)