Skip to content

Commit 0cfcb46

Browse files
committed
fix: update mutes and blocks unit tests
1 parent 9cf0ced commit 0cfcb46

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/__tests__/screens/settings/privacy/BlockedAccountsScreen.test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import { navigationRef } from '@/navigation/navigationRef';
1313
import BlockedAccountsScreen from '@/screens/settings/privacy/BlockedAccountsScreen';
1414
import { PROFILE, ROOT } from '@/utils/navigation/routeNames';
1515

16+
jest.mock('@react-navigation/native', () => {
17+
const actualNav = jest.requireActual('@react-navigation/native');
18+
return {
19+
...actualNav,
20+
useFocusEffect: jest.fn().mockImplementation((callback) => callback()),
21+
};
22+
});
23+
1624
jest.mock('@/hooks/profile/useUserBlocks', () => ({ useUserBlocks: jest.fn() }));
1725
jest.mock('@/hooks/profile/useBlockMutation', () => ({ useBlockMutation: jest.fn() }));
1826
jest.mock('@/hooks/profile/useFollowMutation', () => ({ useFollowMutation: jest.fn() }));

src/__tests__/screens/settings/privacy/MutedAccountsScreen.test.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ import { navigationRef } from '@/navigation/navigationRef';
1313
import MutedAccountsScreen from '@/screens/settings/privacy/MutedAccountsScreen';
1414
import { PROFILE, ROOT } from '@/utils/navigation/routeNames';
1515

16+
jest.mock('@react-navigation/native', () => {
17+
const actualNav = jest.requireActual('@react-navigation/native');
18+
return {
19+
...actualNav,
20+
useFocusEffect: jest.fn().mockImplementation((callback) => callback()),
21+
};
22+
});
1623
jest.mock('@/hooks/profile/useUserMutes', () => ({ useUserMutes: jest.fn() }));
1724
jest.mock('@/hooks/profile/useBlockMutation', () => ({ useBlockMutation: jest.fn() }));
1825
jest.mock('@/hooks/profile/useFollowMutation', () => ({ useFollowMutation: jest.fn() }));
@@ -32,8 +39,9 @@ const setPlatformOS = (os: typeof _initialOS) => {
3239
};
3340

3441
describe('MutedAccountsScreen', () => {
42+
const queryClient = new QueryClient();
43+
3544
const renderWithClient = (ui: ReactElement) => {
36-
const queryClient = new QueryClient();
3745
return render(ui, {
3846
wrapper: ({ children }) => (
3947
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
@@ -42,6 +50,7 @@ describe('MutedAccountsScreen', () => {
4250
};
4351

4452
beforeEach(() => {
53+
queryClient.clear();
4554
jest.clearAllMocks();
4655

4756
(useTheme as jest.Mock).mockReturnValue({ theme: 'light' });

0 commit comments

Comments
 (0)