From 2411c68ee0cb00cb968b7c5a2aad748ecb360245 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Thu, 26 Dec 2024 21:45:01 +0530 Subject: [PATCH] Migrated LeftDrawerOrg.test.tsx from jest to vitest --- ...tDrawerOrg.test.tsx => LeftDrawerOrg.spec.tsx} | 15 ++++++++------- vitest.config.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) rename src/components/LeftDrawerOrg/{LeftDrawerOrg.test.tsx => LeftDrawerOrg.spec.tsx} (98%) diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx similarity index 98% rename from src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx rename to src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx index 71f3593499..3fa6c0205e 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx @@ -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'; @@ -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(); @@ -65,7 +66,7 @@ const props: InterfaceLeftDrawerProps = { }, ], hideDrawer: false, - setHideDrawer: jest.fn(), + setHideDrawer: vi.fn(), }; const MOCKS = [ @@ -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(), }, })); @@ -275,7 +276,7 @@ beforeEach(() => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); localStorage.clear(); }); diff --git a/vitest.config.ts b/vitest.config.ts index 3d071e7534..9d1b41fff4 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -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',