test: Update test files to work with Vitest

This updates the files to be compatible with Vitest. Changes include:
- adding `@testing-library/jest-dom` import to enable custom jest matchers
- renaming `jest.` to `vi.`
- setting flags to false as default where needed
This commit is contained in:
regexowl 2024-06-24 08:46:16 +02:00 committed by Ondřej Ezr
parent da16a42128
commit 2a48966bba
23 changed files with 196 additions and 63 deletions

View file

@ -1,7 +1,8 @@
import '@testing-library/jest-dom';
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import nodeFetch, { Request, Response } from 'node-fetch';
import '@testing-library/jest-dom';
import {
mockComposes,
mockClones,
@ -9,7 +10,9 @@ import {
} from '../../fixtures/composes';
import { renderWithReduxRouter } from '../../testUtils';
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
Object.assign(global, { fetch: nodeFetch, Request, Response });
vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
useChrome: () => ({
isBeta: () => false,
isProd: () => true,
@ -17,9 +20,9 @@ jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
}),
}));
jest.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => jest.fn(),
useFlag: jest.fn((flag) => {
vi.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => vi.fn(),
useFlag: vi.fn((flag) => {
switch (flag) {
case 'edgeParity.image-list':
return false;