@@ -6408,6 +6408,49 @@ test('completes open subscription when "stop" is called', async () => {
6408
6408
expect ( observable . hasObservers ( ) ) . toBe ( false ) ;
6409
6409
} ) ;
6410
6410
6411
+ test ( 'accepts new subscribers after "stop" is called' , async ( ) => {
6412
+ const link = new MockSubscriptionLink ( ) ;
6413
+ const client = new ApolloClient ( {
6414
+ cache : new InMemoryCache ( ) ,
6415
+ link,
6416
+ } ) ;
6417
+ const query = gql `
6418
+ query {
6419
+ greeting
6420
+ }
6421
+ ` ;
6422
+ const observable = client . watchQuery ( { query } ) ;
6423
+ const stream = new ObservableStream ( observable ) ;
6424
+ const firstOperation = link . operation ;
6425
+ expect ( firstOperation ) . toBeDefined ( ) ;
6426
+ await expect ( stream ) . toEmitTypedValue ( {
6427
+ data : undefined ,
6428
+ dataState : "empty" ,
6429
+ loading : true ,
6430
+ networkStatus : NetworkStatus . loading ,
6431
+ partial : true ,
6432
+ } ) ;
6433
+
6434
+ expect ( observable . hasObservers ( ) ) . toBe ( true ) ;
6435
+ observable . stop ( ) ;
6436
+ await expect ( stream ) . toComplete ( ) ;
6437
+ expect ( observable . hasObservers ( ) ) . toBe ( false ) ;
6438
+
6439
+ const stream2 = new ObservableStream ( observable ) ;
6440
+ const secondOperation = link . operation ;
6441
+ expect ( secondOperation ) . toBeDefined ( ) ;
6442
+ expect ( secondOperation ) . not . toBe ( firstOperation ) ;
6443
+ await expect ( stream2 ) . toEmitTypedValue ( {
6444
+ data : undefined ,
6445
+ dataState : "empty" ,
6446
+ loading : true ,
6447
+ networkStatus : NetworkStatus . loading ,
6448
+ partial : true ,
6449
+ } ) ;
6450
+
6451
+ expect ( observable . hasObservers ( ) ) . toBe ( true ) ;
6452
+ } ) ;
6453
+
6411
6454
test ( 'completes open subscription when "client.stop" is called' , async ( ) => {
6412
6455
const link = new MockSubscriptionLink ( ) ;
6413
6456
const client = new ApolloClient ( {
0 commit comments