Skip to content

Commit c949207

Browse files
committed
chore(test): centralize react-native-incall-manager mock in jest.setup
Move the InCallManager stub to setupFilesAfterEnv and remove duplicate jest.mock blocks from VoIP-related tests. Made-with: Cursor
1 parent d76fa82 commit c949207

5 files changed

Lines changed: 7 additions & 25 deletions

File tree

app/containers/MediaCallHeader/MediaCallHeader.test.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ import { mockedStore } from '../../reducers/mockedStore';
99
import * as stories from './MediaCallHeader.stories';
1010
import { generateSnapshots } from '../../../.rnstorybook/generateSnapshots';
1111

12-
jest.mock('react-native-incall-manager', () => ({
13-
start: jest.fn(),
14-
stop: jest.fn(),
15-
setForceSpeakerphoneOn: jest.fn()
16-
}));
17-
1812
const mockNavigateToCallRoom = jest.mocked(navigateToCallRoom);
1913

2014
jest.mock('../../lib/services/voip/navigateToCallRoom', () => ({

app/lib/services/voip/useCallStore.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ jest.mock('../../../containers/ActionSheet', () => ({
1313

1414
jest.mock('react-native-callkeep', () => ({}));
1515

16-
jest.mock('react-native-incall-manager', () => ({
17-
start: jest.fn(),
18-
stop: jest.fn(),
19-
setForceSpeakerphoneOn: jest.fn()
20-
}));
21-
22-
function createMockCall(callId: string) {
16+
function createMockCall(callId: string): IClientMediaCall {
2317
const listeners: Record<string, Set<(...args: unknown[]) => void>> = {};
2418
const emitter = {
2519
on: (ev: string, fn: (...args: unknown[]) => void) => {

app/views/CallView/components/CallButtons.test.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ import { useCallStore } from '../../../lib/services/voip/useCallStore';
77
import { navigateToCallRoom } from '../../../lib/services/voip/navigateToCallRoom';
88
import { CallButtons } from './CallButtons';
99

10-
jest.mock('react-native-incall-manager', () => ({
11-
start: jest.fn(),
12-
stop: jest.fn(),
13-
setForceSpeakerphoneOn: jest.fn()
14-
}));
15-
1610
jest.mock('../../../lib/services/voip/navigateToCallRoom', () => ({
1711
navigateToCallRoom: jest.fn().mockResolvedValue(undefined)
1812
}));

app/views/CallView/components/Dialpad/Dialpad.test.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ import { mockedStore } from '../../../../reducers/mockedStore';
88
import * as stories from './Dialpad.stories';
99
import { generateSnapshots } from '../../../../../.rnstorybook/generateSnapshots';
1010

11-
jest.mock('react-native-incall-manager', () => ({
12-
start: jest.fn(),
13-
stop: jest.fn(),
14-
setForceSpeakerphoneOn: jest.fn(() => Promise.resolve())
15-
}));
16-
1711
const sendDTMFMock = jest.fn();
1812

1913
// Helper to set store state for tests

jest.setup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ jest.mock('react-native-file-viewer', () => ({
3838
open: jest.fn(() => null)
3939
}));
4040

41+
jest.mock('react-native-incall-manager', () => ({
42+
start: jest.fn(),
43+
stop: jest.fn(),
44+
setForceSpeakerphoneOn: jest.fn(() => Promise.resolve())
45+
}));
46+
4147
jest.mock('expo-haptics', () => ({
4248
impactAsync: jest.fn(),
4349
ImpactFeedbackStyle: {

0 commit comments

Comments
 (0)