Skip to content

Commit

Permalink
Refactor src/components/CollapsibleDropdown/CollapsibleDropdown.test.…
Browse files Browse the repository at this point in the history
…tsx from Jest to Vitest #2809 (#2868)

* file name changed

* migrated from jest to vitest
  • Loading branch information
Ramneet04 authored Dec 25, 2024
1 parent c57559e commit 5feefcd
Showing 1 changed file with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5feefcd

Please sign in to comment.