11/**
22 * @jest -environment node
33 *
4- * iOS-only mute tests: requires isIOS = true so performSetMutedCallAction listener is registered.
4+ * iOS-only mute tests: requires isIOS = true so didPerformSetMutedCallAction listener is registered.
55 */
6- import { DeviceEventEmitter } from 'react-native' ;
7- import RNCallKeep from 'react-native-callkeep' ;
8-
9- import { DEEP_LINKING } from '../../../actions/actionsTypes' ;
10- import type { VoipPayload } from '../../../definitions/Voip' ;
11- import NativeVoipModule from '../../native/NativeVoip' ;
12- import { getInitialMediaCallEvents , setupMediaCallEvents } from './MediaCallEvents' ;
6+ import { setupMediaCallEvents } from './MediaCallEvents' ;
137import { useCallStore } from './useCallStore' ;
148
15- const mockDispatch = jest . fn ( ) ;
16- const mockSetNativeAcceptedCallId = jest . fn ( ) ;
179const mockAddEventListener = jest . fn ( ) ;
18- const mockRNCallKeepClearInitialEvents = jest . fn ( ) ;
19- const mockSetCurrentCallActive = jest . fn ( ) ;
2010
2111jest . mock ( '../../methods/helpers' , ( ) => ( {
2212 ...jest . requireActual ( '../../methods/helpers' ) ,
2313 isIOS : true
2414} ) ) ;
2515
26- jest . mock ( '../../store' , ( ) => ( {
27- __esModule : true ,
28- default : {
29- dispatch : ( ...args : unknown [ ] ) => mockDispatch ( ...args )
30- }
31- } ) ) ;
32-
3316jest . mock ( './useCallStore' , ( ) => ( {
3417 useCallStore : {
3518 getState : jest . fn ( )
3619 }
3720} ) ) ;
3821
39- jest . mock ( '../../native/NativeVoip' , ( ) => ( {
40- __esModule : true ,
41- default : {
42- clearInitialEvents : jest . fn ( ) ,
43- getInitialEvents : jest . fn ( ( ) => null )
44- }
45- } ) ) ;
46-
4722jest . mock ( 'react-native-callkeep' , ( ) => ( {
4823 __esModule : true ,
4924 default : {
5025 addEventListener : ( ...args : unknown [ ] ) => mockAddEventListener ( ...args ) ,
51- clearInitialEvents : ( ... args : unknown [ ] ) => mockRNCallKeepClearInitialEvents ( ... args ) ,
52- setCurrentCallActive : ( ... args : unknown [ ] ) => mockSetCurrentCallActive ( ... args ) ,
26+ clearInitialEvents : jest . fn ( ) ,
27+ setCurrentCallActive : jest . fn ( ) ,
5328 getInitialEvents : jest . fn ( ( ) => Promise . resolve ( [ ] ) )
5429 }
5530} ) ) ;
5631
57- jest . mock ( './MediaSessionInstance' , ( ) => ( {
58- mediaSessionInstance : {
59- endCall : jest . fn ( )
60- }
61- } ) ) ;
62-
63- jest . mock ( '../restApi' , ( ) => ( {
64- registerPushToken : jest . fn ( ( ) => Promise . resolve ( ) )
65- } ) ) ;
66-
6732const activeCallBase = {
6833 call : { } as object ,
6934 callId : 'uuid-1' ,
7035 nativeAcceptedCallId : null as string | null
7136} ;
7237
7338function getMuteHandler ( ) : ( payload : { muted : boolean ; callUUID : string } ) => void {
74- const call = mockAddEventListener . mock . calls . find ( ( [ name ] ) => name === 'performSetMutedCallAction ' ) ;
39+ const call = mockAddEventListener . mock . calls . find ( ( [ name ] ) => name === 'didPerformSetMutedCallAction ' ) ;
7540 if ( ! call ) {
76- throw new Error ( 'performSetMutedCallAction listener not registered' ) ;
41+ throw new Error ( 'didPerformSetMutedCallAction listener not registered' ) ;
7742 }
7843 return call [ 1 ] as ( payload : { muted : boolean ; callUUID : string } ) => void ;
7944}
8045
81- describe ( 'setupMediaCallEvents — performSetMutedCallAction (iOS)' , ( ) => {
46+ describe ( 'setupMediaCallEvents — didPerformSetMutedCallAction (iOS)' , ( ) => {
8247 const toggleMute = jest . fn ( ) ;
8348 const getState = useCallStore . getState as jest . Mock ;
8449
@@ -89,9 +54,9 @@ describe('setupMediaCallEvents — performSetMutedCallAction (iOS)', () => {
8954 getState . mockReturnValue ( { ...activeCallBase , isMuted : false , toggleMute } ) ;
9055 } ) ;
9156
92- it ( 'registers performSetMutedCallAction via RNCallKeep.addEventListener' , ( ) => {
57+ it ( 'registers didPerformSetMutedCallAction via RNCallKeep.addEventListener' , ( ) => {
9358 setupMediaCallEvents ( ) ;
94- expect ( mockAddEventListener ) . toHaveBeenCalledWith ( 'performSetMutedCallAction ' , expect . any ( Function ) ) ;
59+ expect ( mockAddEventListener ) . toHaveBeenCalledWith ( 'didPerformSetMutedCallAction ' , expect . any ( Function ) ) ;
9560 } ) ;
9661
9762 it ( 'calls toggleMute when muted state differs from OS and UUIDs match' , ( ) => {
0 commit comments