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