@@ -307,7 +307,7 @@ describe('LiveQueryClient', () => {
307
307
expect ( liveQueryClient . subscriptions . size ) . toBe ( 1 ) ;
308
308
} ) ;
309
309
310
- it ( 'can handle WebSocket error response message' , ( ) => {
310
+ it ( 'can handle WebSocket error response message' , async ( ) => {
311
311
const liveQueryClient = new LiveQueryClient ( {
312
312
applicationId : 'applicationId' ,
313
313
serverURL : 'ws://test' ,
@@ -329,13 +329,17 @@ describe('LiveQueryClient', () => {
329
329
isChecked = true ;
330
330
expect ( error ) . toEqual ( 'error' ) ;
331
331
} ) ;
332
-
333
- liveQueryClient . _handleWebSocketMessage ( event ) ;
332
+ try {
333
+ liveQueryClient . _handleWebSocketMessage ( event ) ;
334
+ await liveQueryClient . connectPromise ;
335
+ } catch ( error ) {
336
+ expect ( error . message ) . toEqual ( 'error' ) ;
337
+ }
334
338
335
339
expect ( isChecked ) . toBe ( true ) ;
336
340
} ) ;
337
341
338
- it ( 'can handle WebSocket error while subscribing' , ( ) => {
342
+ it ( 'can handle WebSocket error while subscribing' , async ( ) => {
339
343
const liveQueryClient = new LiveQueryClient ( {
340
344
applicationId : 'applicationId' ,
341
345
serverURL : 'ws://test' ,
@@ -363,7 +367,12 @@ describe('LiveQueryClient', () => {
363
367
expect ( error ) . toEqual ( 'error thrown' ) ;
364
368
} ) ;
365
369
366
- liveQueryClient . _handleWebSocketMessage ( event ) ;
370
+ try {
371
+ liveQueryClient . _handleWebSocketMessage ( event ) ;
372
+ await Promise . all ( [ subscription . connectPromise , subscription . subscribePromise , liveQueryClient . connectPromise , liveQueryClient . subscribePromise ] ) ;
373
+ } catch ( e ) {
374
+ expect ( e . message ) . toEqual ( 'error thrown' ) ;
375
+ }
367
376
368
377
jest . runOnlyPendingTimers ( ) ;
369
378
expect ( isChecked ) . toBe ( true ) ;
@@ -740,7 +749,7 @@ describe('LiveQueryClient', () => {
740
749
liveQueryClient . _handleWebSocketError ( error ) ;
741
750
} ) ;
742
751
743
- it ( 'can handle WebSocket reconnect on error event' , ( ) => {
752
+ it ( 'can handle WebSocket reconnect on error event' , async ( ) => {
744
753
const liveQueryClient = new LiveQueryClient ( {
745
754
applicationId : 'applicationId' ,
746
755
serverURL : 'ws://test' ,
@@ -764,7 +773,12 @@ describe('LiveQueryClient', () => {
764
773
expect ( error ) . toEqual ( data . error ) ;
765
774
} ) ;
766
775
const spy = jest . spyOn ( liveQueryClient , '_handleReconnect' ) ;
767
- liveQueryClient . _handleWebSocketMessage ( event ) ;
776
+ try {
777
+ liveQueryClient . _handleWebSocketMessage ( event ) ;
778
+ await liveQueryClient . connectPromise ;
779
+ } catch ( e ) {
780
+ expect ( e . message ) . toBe ( 'Additional properties not allowed' ) ;
781
+ }
768
782
769
783
expect ( isChecked ) . toBe ( true ) ;
770
784
expect ( liveQueryClient . _handleReconnect ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments