From 9e7f09ed6bc9da2ff49d8fa9a9b5cb8ea13d9284 Mon Sep 17 00:00:00 2001 From: sirineJ <112706079+sirineJ@users.noreply.github.com> Date: Tue, 7 Jan 2025 18:36:10 +0100 Subject: [PATCH] fix tests --- .../MobileNavigation.spec.tsx | 2 ++ .../SidePanel/SidePanelContext.spec.tsx | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/circuit-ui/components/SideNavigation/components/MobileNavigation/MobileNavigation.spec.tsx b/packages/circuit-ui/components/SideNavigation/components/MobileNavigation/MobileNavigation.spec.tsx index 6040a08501..128c2e619a 100644 --- a/packages/circuit-ui/components/SideNavigation/components/MobileNavigation/MobileNavigation.spec.tsx +++ b/packages/circuit-ui/components/SideNavigation/components/MobileNavigation/MobileNavigation.spec.tsx @@ -31,6 +31,8 @@ import { type MobileNavigationProps, } from './MobileNavigation.js'; +vi.mock('../../../../hooks/useMedia/index.js'); + describe('MobileNavigation', () => { function renderMobileNavigation( renderFn: RenderFn, diff --git a/packages/circuit-ui/components/SidePanel/SidePanelContext.spec.tsx b/packages/circuit-ui/components/SidePanel/SidePanelContext.spec.tsx index 2b1c3d6295..bca7fa74ea 100644 --- a/packages/circuit-ui/components/SidePanel/SidePanelContext.spec.tsx +++ b/packages/circuit-ui/components/SidePanel/SidePanelContext.spec.tsx @@ -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, @@ -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 {children}; + }, +})); + describe('SidePanelContext', () => { beforeAll(() => { vi.useFakeTimers();