From 108cb1d2a33290a43b9e23df0b4069198aa34838 Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Wed, 25 Dec 2024 16:48:02 +0530 Subject: [PATCH 1/2] file name changed --- ...{CollapsibleDropdown.test.tsx => CollapsibleDropdown.spec.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/components/CollapsibleDropdown/{CollapsibleDropdown.test.tsx => CollapsibleDropdown.spec.tsx} (100%) diff --git a/src/components/CollapsibleDropdown/CollapsibleDropdown.test.tsx b/src/components/CollapsibleDropdown/CollapsibleDropdown.spec.tsx similarity index 100% rename from src/components/CollapsibleDropdown/CollapsibleDropdown.test.tsx rename to src/components/CollapsibleDropdown/CollapsibleDropdown.spec.tsx From 34522d82f57de14b39ed8b9264e72eb409451173 Mon Sep 17 00:00:00 2001 From: Ramneet04 Date: Wed, 25 Dec 2024 18:31:40 +0530 Subject: [PATCH 2/2] migrated from jest to vitest --- .../CollapsibleDropdown.spec.tsx | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/components/CollapsibleDropdown/CollapsibleDropdown.spec.tsx b/src/components/CollapsibleDropdown/CollapsibleDropdown.spec.tsx index efee248ffb..b288fb9de5 100644 --- a/src/components/CollapsibleDropdown/CollapsibleDropdown.spec.tsx +++ b/src/components/CollapsibleDropdown/CollapsibleDropdown.spec.tsx @@ -8,21 +8,33 @@ import { store } from 'state/store'; import { Provider } from 'react-redux'; import { I18nextProvider } from 'react-i18next'; import i18nForTest from 'utils/i18nForTest'; +import { describe, expect, test, vi, afterEach } from 'vitest'; +import type { Location } from '@remix-run/router'; -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), - useLocation: () => ({ - pathname: '/orgstore', - state: {}, - key: '', - search: '', - hash: '', - }), -})); +afterEach(() => { + vi.resetModules(); +}); + +const currentLocation: Location = { + pathname: '/orgstore', + state: {}, + key: '', + search: '', + hash: '', +}; + +vi.mock('react-router-dom', async (importOriginal) => { + const mod = (await importOriginal()) as object; + + return { + ...mod, + useLocation: () => currentLocation, + }; +}); const props: InterfaceCollapsibleDropdown = { showDropdown: true, - setShowDropdown: jest.fn(), + setShowDropdown: vi.fn(), target: { name: 'DropDown Category', url: undefined,