Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refacted : src/components/LeftDrawer/LeftDrawer.test.tsx from Jest to Vitest #3134

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
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 } from 'react-router-dom';

import i18nForTest from 'utils/i18nForTest';
import type { InterfaceLeftDrawerProps } from './LeftDrawer';
import LeftDrawer from './LeftDrawer';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import { StaticMockLink } from 'utils/StaticMockLink';
import { MockedProvider } from '@apollo/react-testing';
import useLocalStorage from 'utils/useLocalstorage';
import { vi, it, describe, beforeEach, afterEach, expect } from 'vitest';

const { setItem } = useLocalStorage();

const props = {
hideDrawer: true,
setHideDrawer: jest.fn(),
setHideDrawer: vi.fn(),
};

const resizeWindow = (width: number): void => {
Expand All @@ -40,11 +39,11 @@ const MOCKS = [

const link = new StaticMockLink(MOCKS, true);

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 @@ -58,12 +57,12 @@ beforeEach(() => {
});

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

describe('Testing Left Drawer component for SUPERADMIN', () => {
test('Component should be rendered properly', async () => {
it('Component should be rendered properly', async () => {
setItem('UserImage', '');
setItem('SuperAdmin', true);
setItem('FirstName', 'John');
Expand Down Expand Up @@ -113,7 +112,7 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
});
});

test('Testing Drawer when hideDrawer is null', async () => {
it('Testing Drawer when hideDrawer is null', async () => {
const tempProps: InterfaceLeftDrawerProps = {
...props,
hideDrawer: false,
Expand All @@ -132,7 +131,7 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
});
});

test('Testing Drawer when hideDrawer is false', async () => {
it('Testing Drawer when hideDrawer is false', async () => {
const tempProps: InterfaceLeftDrawerProps = {
...props,
hideDrawer: false,
Expand All @@ -151,7 +150,7 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
});
});

test('Testing Drawer when the screen size is less than or equal to 820px', async () => {
it('Testing Drawer when the screen size is less than or equal to 820px', async () => {
const tempProps: InterfaceLeftDrawerProps = {
...props,
hideDrawer: false,
Expand Down Expand Up @@ -184,7 +183,7 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
});

describe('Testing Left Drawer component for ADMIN', () => {
test('Components should be rendered properly', async () => {
it('Components should be rendered properly', async () => {
await act(async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand Down
Loading