File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -760,7 +760,7 @@ describe('Subscription Publish Phase', () => {
760
760
761
761
it ( 'should not trigger when subscription is thrown' , async ( ) => {
762
762
const pubsub = new SimplePubSub < Email > ( ) ;
763
- const subscription = createSubscription ( pubsub ) ;
763
+ const subscription = await createSubscription ( pubsub ) ;
764
764
assert ( isAsyncIterable ( subscription ) ) ;
765
765
766
766
let payload = subscription . next ( ) ;
@@ -793,17 +793,23 @@ describe('Subscription Publish Phase', () => {
793
793
} ,
794
794
} ) ;
795
795
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 ) ;
796
800
payload = subscription . next ( ) ;
797
801
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 ) ;
807
813
808
814
expect ( await payload ) . to . deep . equal ( {
809
815
done : true ,
You can’t perform that action at this time.
0 commit comments