Skip to content

Commit 7497e09

Browse files
committed
fix useRecording test
1 parent affcd84 commit 7497e09

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

test/hooks/useRecording.test.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ import DailyIframe, {
1212
import { act, renderHook } from '@testing-library/react-hooks';
1313
import faker from 'faker';
1414
import React from 'react';
15-
import { RecoilRoot } from 'recoil';
1615

1716
import { DailyProvider } from '../../src/DailyProvider';
1817
import { useRecording } from '../../src/hooks/useRecording';
1918

19+
const localId = faker.datatype.uuid();
20+
21+
jest.mock('../../src/hooks/useLocalParticipant', () => ({
22+
useLocalParticipant: () => ({ session_id: localId }),
23+
}));
24+
2025
const createWrapper =
2126
(callObject: DailyCall = DailyIframe.createCallObject()): React.FC =>
2227
({ children }) =>
23-
(
24-
<DailyProvider callObject={callObject}>
25-
<RecoilRoot>{children}</RecoilRoot>
26-
</DailyProvider>
27-
);
28+
<DailyProvider callObject={callObject}>{children}</DailyProvider>;
2829

2930
describe('useRecording', () => {
3031
it('returns default state and functions', async () => {
@@ -185,16 +186,12 @@ describe('useRecording', () => {
185186
});
186187
it('single-participant recording for other participant sets isLocalParticipantRecorded to false', async () => {
187188
const daily = DailyIframe.createCallObject();
188-
const localId = faker.datatype.uuid();
189-
const otherId = faker.datatype.uuid();
189+
const otherId = 'other';
190190
(daily.participants as jest.Mock).mockImplementation(() => ({
191191
local: {
192192
session_id: localId,
193193
},
194194
}));
195-
jest.mock('../../src/hooks/useLocalParticipant', () => ({
196-
useLocalParticipant: () => ({ session_id: localId }),
197-
}));
198195
const { result, waitFor } = renderHook(() => useRecording(), {
199196
wrapper: createWrapper(daily),
200197
});
@@ -207,7 +204,7 @@ describe('useRecording', () => {
207204
},
208205
local: false,
209206
recordingId: faker.datatype.uuid(),
210-
startedBy: faker.datatype.uuid(),
207+
startedBy: localId,
211208
type: 'cloud',
212209
};
213210
act(() => {

0 commit comments

Comments
 (0)