Skip to content

Commit

Permalink
Refactor: Migrated src/components/OrgAdminListCard/OrgAdminListCard.t…
Browse files Browse the repository at this point in the history
…est.tsx from Jest to Vitest (#2908)
  • Loading branch information
PratapRathi authored Dec 26, 2024
1 parent 3209a18 commit 9105989
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import OrgAdminListCard from './OrgAdminListCard';
import i18nForTest from 'utils/i18nForTest';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { StaticMockLink } from 'utils/StaticMockLink';
import { vi, beforeEach, afterEach, expect, it, describe } from 'vitest';

const MOCKS = [
{
Expand Down Expand Up @@ -57,27 +58,28 @@ const renderOrgAdminListCard = (props: {
</MockedProvider>,
);
};
jest.mock('i18next-browser-languagedetector', () => ({
init: jest.fn(),
vi.mock('i18next-browser-languagedetector', async () => ({
...(await vi.importActual('i18next-browser-languagedetector')),
init: vi.fn(),
type: 'languageDetector',
detect: jest.fn(() => 'en'),
cacheUserLanguage: jest.fn(),
detect: vi.fn(() => 'en'),
cacheUserLanguage: vi.fn(),
}));
describe('Testing Organization Admin List Card', () => {
global.alert = jest.fn();
global.alert = vi.fn();

beforeEach(() => {
Object.defineProperty(window, 'location', {
writable: true,
value: { reload: jest.fn() },
value: { reload: vi.fn() },
});
});

afterEach(() => {
jest.restoreAllMocks();
vi.restoreAllMocks();
});

test('should render props and text elements test for the page component', async () => {
it('should render props and text elements test for the page component', async () => {
const props = {
toggleRemoveModal: () => true,
id: '456',
Expand All @@ -92,7 +94,7 @@ describe('Testing Organization Admin List Card', () => {
await wait(2000);
});

test('Should not render text elements when props value is not passed', async () => {
it('Should not render text elements when props value is not passed', async () => {
const props = {
toggleRemoveModal: () => true,
id: undefined,
Expand Down

0 comments on commit 9105989

Please sign in to comment.