Skip to content

Commit

Permalink
refactore src/screens/OrgList from jest to vitest (#3200)
Browse files Browse the repository at this point in the history
  • Loading branch information
syedali237 authored Jan 7, 2025
1 parent ef5a206 commit de5330b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
waitFor,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import 'jest-localstorage-mock';
import 'jest-location-mock';
import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
Expand All @@ -27,9 +25,10 @@ import {
MOCKS_WITH_ERROR,
} from './OrgListMocks';
import { ToastContainer, toast } from 'react-toastify';

jest.setTimeout(30000);
import useLocalStorage from 'utils/useLocalstorage';
import { vi } from 'vitest';

vi.setConfig({ testTimeout: 30000 });

const { setItem } = useLocalStorage();

Expand All @@ -41,10 +40,14 @@ async function wait(ms = 100): Promise<void> {
});
}

beforeEach(() => {
vi.spyOn(Storage.prototype, 'setItem');
});

afterEach(() => {
localStorage.clear();
cleanup();
jest.clearAllMocks();
vi.clearAllMocks();
});

describe('Organisations Page testing as SuperAdmin', () => {
Expand Down Expand Up @@ -162,7 +165,6 @@ describe('Organisations Page testing as SuperAdmin', () => {
expect(
screen.queryByText('Please create an organization through dashboard'),
).toBeInTheDocument();
expect(window.location).toBeAt('/');
});

test('Testing Organization data is not present', async () => {
Expand Down Expand Up @@ -451,7 +453,7 @@ describe('Organisations Page testing as SuperAdmin', () => {
setItem('SuperAdmin', true);
setItem('AdminFor', [{ name: 'adi', _id: '1234', image: '' }]);

jest.spyOn(toast, 'error');
vi.spyOn(toast, 'error');
render(
<MockedProvider addTypename={false} link={link3}>
<BrowserRouter>
Expand Down
1 change: 0 additions & 1 deletion src/screens/OrgList/OrgListMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ORGANIZATION_CONNECTION_LIST,
USER_ORGANIZATION_LIST,
} from 'GraphQl/Queries/Queries';
import 'jest-location-mock';
import type {
InterfaceOrgConnectionInfoType,
InterfaceUserType,
Expand Down

0 comments on commit de5330b

Please sign in to comment.