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

[REFACTOR]: Jest to Vitest migration for UserListCard.test.tsx #2924

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 4 additions & 5 deletions src/components/CheckIn/tagTemplate.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { act } from 'react';
import { render, screen } from '@testing-library/react';
import React from 'react';
import { render, screen, act } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import userEvent from '@testing-library/user-event';
import { I18nextProvider } from 'react-i18next';
Expand All @@ -9,6 +9,7 @@ import { ADD_ADMIN_MUTATION } from 'GraphQl/Mutations/mutations';
import i18nForTest from 'utils/i18nForTest';
import { BrowserRouter } from 'react-router-dom';
import { StaticMockLink } from 'utils/StaticMockLink';
import { vi, describe, it, beforeEach } from 'vitest';

const MOCKS = [
{
Expand All @@ -30,17 +31,15 @@ const MOCKS = [
const link = new StaticMockLink(MOCKS, true);

async function wait(ms = 100): Promise<void> {
await act(() => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
});
await act(() => new Promise((resolve) => setTimeout(resolve, ms)));
}

describe('Testing User List Card', () => {
global.alert = jest.fn();
beforeEach(() => {
vi.spyOn(global, 'alert').mockImplementation(() => {});
});

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 = {
id: '456',
};
Expand All @@ -56,11 +55,10 @@ describe('Testing User List Card', () => {
);

await wait();

userEvent.click(screen.getByText(/Add Admin/i));
});

test('Should render text elements when props value is not passed', async () => {
it('Should render text elements when props value is not passed', async () => {
const props = {
id: '456',
};
Expand Down
Loading