@@ -122,18 +122,24 @@ describe("useEcho hook", async () => {
122
122
123
123
const channel = echoInstance . private ( channelName ) ;
124
124
125
- expect ( channel . listen ) . toHaveBeenCalledWith ( events [ 0 ] , mockCallback ) ;
126
- expect ( channel . listen ) . toHaveBeenCalledWith ( events [ 1 ] , mockCallback ) ;
125
+ expect ( channel . listen ) . toHaveBeenCalledWith (
126
+ events [ 0 ] ,
127
+ expect . any ( Function ) ,
128
+ ) ;
129
+ expect ( channel . listen ) . toHaveBeenCalledWith (
130
+ events [ 1 ] ,
131
+ expect . any ( Function ) ,
132
+ ) ;
127
133
128
134
expect ( ( ) => unmount ( ) ) . not . toThrow ( ) ;
129
135
130
136
expect ( channel . stopListening ) . toHaveBeenCalledWith (
131
137
events [ 0 ] ,
132
- mockCallback ,
138
+ expect . any ( Function ) ,
133
139
) ;
134
140
expect ( channel . stopListening ) . toHaveBeenCalledWith (
135
141
events [ 1 ] ,
136
- mockCallback ,
142
+ expect . any ( Function ) ,
137
143
) ;
138
144
} ) ;
139
145
@@ -190,7 +196,7 @@ describe("useEcho hook", async () => {
190
196
191
197
expect ( echoInstance . private ( channelName ) . listen ) . toHaveBeenCalledWith (
192
198
event ,
193
- mockCallback ,
199
+ expect . any ( Function ) ,
194
200
) ;
195
201
} ) ;
196
202
@@ -251,15 +257,24 @@ describe("useEcho hook", async () => {
251
257
252
258
const channel = echoInstance . private ( channelName ) ;
253
259
254
- expect ( channel . listen ) . toHaveBeenCalledWith ( event , mockCallback ) ;
260
+ expect ( channel . listen ) . toHaveBeenCalledWith (
261
+ event ,
262
+ expect . any ( Function ) ,
263
+ ) ;
255
264
256
265
result . current . stopListening ( ) ;
257
266
258
- expect ( channel . stopListening ) . toHaveBeenCalledWith ( event , mockCallback ) ;
267
+ expect ( channel . stopListening ) . toHaveBeenCalledWith (
268
+ event ,
269
+ expect . any ( Function ) ,
270
+ ) ;
259
271
260
272
result . current . listen ( ) ;
261
273
262
- expect ( channel . listen ) . toHaveBeenCalledWith ( event , mockCallback ) ;
274
+ expect ( channel . listen ) . toHaveBeenCalledWith (
275
+ event ,
276
+ expect . any ( Function ) ,
277
+ ) ;
263
278
} ) ;
264
279
265
280
it ( "can manually stop listening to events" , async ( ) => {
@@ -274,7 +289,10 @@ describe("useEcho hook", async () => {
274
289
result . current . stopListening ( ) ;
275
290
276
291
const channel = echoInstance . private ( channelName ) ;
277
- expect ( channel . stopListening ) . toHaveBeenCalledWith ( event , mockCallback ) ;
292
+ expect ( channel . stopListening ) . toHaveBeenCalledWith (
293
+ event ,
294
+ expect . any ( Function ) ,
295
+ ) ;
278
296
} ) ;
279
297
280
298
it ( "stopListening is a no-op when not listening" , async ( ) => {
@@ -387,22 +405,22 @@ describe("useEchoModel hook", async () => {
387
405
388
406
expect ( channel . listen ) . toHaveBeenCalledWith (
389
407
`.${ events [ 0 ] } ` ,
390
- mockCallback ,
408
+ expect . any ( Function ) ,
391
409
) ;
392
410
expect ( channel . listen ) . toHaveBeenCalledWith (
393
411
`.${ events [ 1 ] } ` ,
394
- mockCallback ,
412
+ expect . any ( Function ) ,
395
413
) ;
396
414
397
415
expect ( ( ) => unmount ( ) ) . not . toThrow ( ) ;
398
416
399
417
expect ( channel . stopListening ) . toHaveBeenCalledWith (
400
418
`.${ events [ 0 ] } ` ,
401
- mockCallback ,
419
+ expect . any ( Function ) ,
402
420
) ;
403
421
expect ( channel . stopListening ) . toHaveBeenCalledWith (
404
422
`.${ events [ 1 ] } ` ,
405
- mockCallback ,
423
+ expect . any ( Function ) ,
406
424
) ;
407
425
} ) ;
408
426
@@ -531,7 +549,10 @@ describe("useEchoModel hook", async () => {
531
549
expect ( echoInstance . private ) . toHaveBeenCalledWith ( expectedChannelName ) ;
532
550
533
551
const channel = echoInstance . private ( expectedChannelName ) ;
534
- expect ( channel . listen ) . toHaveBeenCalledWith ( `.${ event } ` , mockCallback ) ;
552
+ expect ( channel . listen ) . toHaveBeenCalledWith (
553
+ `.${ event } ` ,
554
+ expect . any ( Function ) ,
555
+ ) ;
535
556
} ) ;
536
557
537
558
it ( "events and listeners are optional" , async ( ) => {
@@ -601,18 +622,24 @@ describe("useEchoPublic hook", async () => {
601
622
602
623
const channel = echoInstance . channel ( channelName ) ;
603
624
604
- expect ( channel . listen ) . toHaveBeenCalledWith ( events [ 0 ] , mockCallback ) ;
605
- expect ( channel . listen ) . toHaveBeenCalledWith ( events [ 1 ] , mockCallback ) ;
625
+ expect ( channel . listen ) . toHaveBeenCalledWith (
626
+ events [ 0 ] ,
627
+ expect . any ( Function ) ,
628
+ ) ;
629
+ expect ( channel . listen ) . toHaveBeenCalledWith (
630
+ events [ 1 ] ,
631
+ expect . any ( Function ) ,
632
+ ) ;
606
633
607
634
expect ( ( ) => unmount ( ) ) . not . toThrow ( ) ;
608
635
609
636
expect ( channel . stopListening ) . toHaveBeenCalledWith (
610
637
events [ 0 ] ,
611
- mockCallback ,
638
+ expect . any ( Function ) ,
612
639
) ;
613
640
expect ( channel . stopListening ) . toHaveBeenCalledWith (
614
641
events [ 1 ] ,
615
- mockCallback ,
642
+ expect . any ( Function ) ,
616
643
) ;
617
644
} ) ;
618
645
@@ -755,18 +782,24 @@ describe("useEchoPresence hook", async () => {
755
782
756
783
const channel = echoInstance . join ( channelName ) ;
757
784
758
- expect ( channel . listen ) . toHaveBeenCalledWith ( events [ 0 ] , mockCallback ) ;
759
- expect ( channel . listen ) . toHaveBeenCalledWith ( events [ 1 ] , mockCallback ) ;
785
+ expect ( channel . listen ) . toHaveBeenCalledWith (
786
+ events [ 0 ] ,
787
+ expect . any ( Function ) ,
788
+ ) ;
789
+ expect ( channel . listen ) . toHaveBeenCalledWith (
790
+ events [ 1 ] ,
791
+ expect . any ( Function ) ,
792
+ ) ;
760
793
761
794
expect ( ( ) => unmount ( ) ) . not . toThrow ( ) ;
762
795
763
796
expect ( channel . stopListening ) . toHaveBeenCalledWith (
764
797
events [ 0 ] ,
765
- mockCallback ,
798
+ expect . any ( Function ) ,
766
799
) ;
767
800
expect ( channel . stopListening ) . toHaveBeenCalledWith (
768
801
events [ 1 ] ,
769
- mockCallback ,
802
+ expect . any ( Function ) ,
770
803
) ;
771
804
} ) ;
772
805
0 commit comments