Skip to content

Commit

Permalink
Migrated LeftDrawerOrg.test.tsx from jest to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
gracefullcoder committed Dec 26, 2024
1 parent 89aebba commit 2411c68
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
@@ -1,7 +1,7 @@
import '@testing-library/jest-dom';
import React, { act } from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import 'jest-localstorage-mock';
import { I18nextProvider } from 'react-i18next';
import { BrowserRouter, MemoryRouter } from 'react-router-dom';

Expand All @@ -15,6 +15,7 @@ import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries';
import { StaticMockLink } from 'utils/StaticMockLink';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import useLocalStorage from 'utils/useLocalstorage';
import { vi, describe, test, expect } from 'vitest';

const { setItem } = useLocalStorage();

Expand Down Expand Up @@ -65,7 +66,7 @@ const props: InterfaceLeftDrawerProps = {
},
],
hideDrawer: false,
setHideDrawer: jest.fn(),
setHideDrawer: vi.fn(),
};

const MOCKS = [
Expand Down Expand Up @@ -244,11 +245,11 @@ const defaultScreens = [
'All Organizations',
];

jest.mock('react-toastify', () => ({
vi.mock('react-toastify', () => ({
toast: {
success: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
success: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
},
}));

Expand All @@ -275,7 +276,7 @@ beforeEach(() => {
});

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

Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
svgrPlugin(),
],
test: {
include: ['src/**/*.spec.{js,jsx,ts,tsx}'],
include: ['src/components/LeftDrawerOrg/*.spec.{js,jsx,ts,tsx}'],
globals: true,
environment: 'jsdom',
setupFiles: 'vitest.setup.ts',
Expand Down

0 comments on commit 2411c68

Please sign in to comment.