Skip to content

Commit 20a6b20

Browse files
committed
test: refactor tests with vitest
1 parent 8d0045e commit 20a6b20

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/App.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import React from "react";
55
import userEvent from "@testing-library/user-event";
66
import { IResponse } from "./types/speakers";
77
import axios, { AxiosHeaders, AxiosResponse } from "axios";
8+
import { vi } from "vitest";
89

9-
jest.mock("axios");
10+
vi.mock("axios");
1011
const mockedAxios = axios as jest.Mocked<typeof axios>;
1112
const axiosHeaders = new AxiosHeaders();
1213
const payload: AxiosResponse<IResponse[]> = {
@@ -67,11 +68,11 @@ const payload: AxiosResponse<IResponse[]> = {
6768

6869
describe("navigation pages", () => {
6970
beforeAll(() => {
70-
jest.mock("axios");
71+
vi.mock("axios");
7172
mockedAxios.get.mockImplementation(() => Promise.resolve(payload));
7273
});
7374
beforeEach(() => {
74-
jest.clearAllMocks();
75+
vi.clearAllMocks();
7576
});
7677

7778
test("it render the HOME page", async () => {
@@ -164,7 +165,6 @@ describe("navigation pages", () => {
164165
).not.toBeInTheDocument();*/
165166
});
166167

167-
//Reason: not enabled yet
168168
test("it render the CFP page", async () => {
169169
render(
170170
<React.Suspense fallback={<span>Loading...</span>}>

src/views/Talks/Talks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ const Talks: FC<React.PropsWithChildren<unknown>> = () => {
5050
useSentryErrorReport(error);
5151

5252
const removeParenthesesContent = (text: string): string => {
53-
return text.replace(/\s*\([^)]*\)/g, "");
53+
return text?.replace(/\s*\([^)]*\)/g, "");
5454
};
5555

5656
const trackOptions = [
5757
{ name: "All Tracks", code: undefined },
5858
...(data !== undefined
5959
? data
6060
.flatMap((group) => ({
61-
code: group.groupId.toString(),
61+
code: group?.groupId?.toString(),
6262
name: removeParenthesesContent(group.groupName),
6363
}))
6464
.sort((a, b) => a.name.localeCompare(b.name))

0 commit comments

Comments
 (0)