Skip to content

Commit 5849ed1

Browse files
committed
refactor: use it keyword instead of test
1 parent 628bd14 commit 5849ed1

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

__tests__/components/cards/User.test.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import UserCard from "@/components/cards/User";
2-
import { renderWithRedux } from "../../../__mocks__/renderWithRedux";
3-
import { mockUser } from "../../../__mocks__/fixtures/user";
2+
import { renderWithRedux } from "@__mocks__/renderWithRedux";
3+
import { mockUser } from "@__mocks__/fixtures/user";
44
import { fireEvent, screen } from "@testing-library/react";
55
import "@testing-library/jest-dom";
6-
import { useRouter } from "next/router";
76

87
jest.mock("next/router", () => ({
9-
useRouter: jest.fn(),
8+
useRouter: jest.fn(() => ({
9+
locale: "en",
10+
push: mockPush,
11+
})),
1012
}));
1113
const teamMembers = [mockUser];
1214
const handleClick = jest.fn(() => {});
1315
const mockPush = jest.fn();
14-
const mockUseRouter = {
15-
locale: "en",
16-
push: mockPush,
17-
};
18-
(useRouter as jest.Mock).mockReturnValue(mockUseRouter);
1916

2017
describe("User card component", () => {
2118
const timestamp = {
@@ -33,8 +30,7 @@ describe("User card component", () => {
3330
window.getSelection = jest.fn().mockReturnValue({
3431
type: "Caret",
3532
});
36-
test("Renders the card component", () => {
37-
const teamMembers = [mockUser];
33+
it("Renders the card component", () => {
3834
expect(screen.getByTestId("userId")).toBeInTheDocument();
3935
expect(screen.getAllByTestId("avatar").length).toEqual(teamMembers.length);
4036
const linkElements = screen.getAllByRole("link");
@@ -46,16 +42,16 @@ describe("User card component", () => {
4642
});
4743
});
4844

49-
test("Renders the correct tag and currecy when teamMembers is not empty", () => {
45+
it("Renders the correct tag and currecy when teamMembers is not empty", () => {
5046
expect(screen.getByTestId("currencyId")).toBeInTheDocument();
5147
expect(screen.getByTestId("tag")).toBeInTheDocument();
5248
});
5349

54-
test("Calls onClick prop when clicked", () => {
50+
it("Calls onClick prop when clicked", () => {
5551
fireEvent.click(screen.getByTestId("userId"));
5652
expect(handleClick).toHaveBeenCalled();
5753
});
58-
test("Navigates to the correct link when clicked", () => {
54+
it("Navigates to the correct link when clicked", () => {
5955
const element = screen.getByText("test link");
6056
fireEvent.click(element);
6157
expect(mockPush).toHaveBeenCalledWith("/testlink");

0 commit comments

Comments
 (0)