Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirineJ committed Jan 7, 2025
1 parent e38f429 commit 9e7f09e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
type MobileNavigationProps,
} from './MobileNavigation.js';

vi.mock('../../../../hooks/useMedia/index.js');

describe('MobileNavigation', () => {
function renderMobileNavigation<T>(
renderFn: RenderFn<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ import {
vi,
type Mock,
} from 'vitest';
import { useContext, type ComponentType } from 'react';
import {
useContext,
type ComponentType,
useEffect,
type ReactNode,
} from 'react';

import {
render,
Expand All @@ -47,6 +52,20 @@ import {

vi.mock('../../hooks/useMedia/index.js');

vi.mock('./SidePanel.js', () => ({
SidePanel: ({
open,
onAfterClose,
children,
}: { open: boolean; onAfterClose?: () => void; children: ReactNode }) => {
useEffect(() => () => {
onAfterClose?.();
}, [onAfterClose]);

return <dialog open={open}>{children}</dialog>;
},
}));

describe('SidePanelContext', () => {
beforeAll(() => {
vi.useFakeTimers();
Expand Down

0 comments on commit 9e7f09e

Please sign in to comment.