From 535dbe5a690ce29aed82498e2de3c5b26775a503 Mon Sep 17 00:00:00 2001 From: Clara Ribeiro Date: Tue, 17 Dec 2024 05:58:16 -0300 Subject: [PATCH 1/4] tests: adiciona teste do membershipService --- src/Services/memberShipService.test.js | 102 +++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/Services/memberShipService.test.js diff --git a/src/Services/memberShipService.test.js b/src/Services/memberShipService.test.js new file mode 100644 index 0000000..01e18f2 --- /dev/null +++ b/src/Services/memberShipService.test.js @@ -0,0 +1,102 @@ +import { describe, it, expect, vi, beforeEach } from "vitest"; +import { + createMemberShip, + getMemberShip, + getMemberShipById, + updateMemberStatus, + updateMembership, + deleteMember, +} from "./memberShipService"; +import { APIUsers } from "./BaseService"; + +vi.mock("../services/BaseService", () => ({ + APIUsers: { + post: vi.fn(), + get: vi.fn(), + patch: vi.fn(), + delete: vi.fn(), + }, +})); + +describe("MembershipService", () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("deve retornar o status correto ao criar uma filiação", async () => { + APIUsers.post.mockResolvedValueOnce({ status: 201 }); + + const result = await createMemberShip({ name: "John Doe" }); + + expect(result).toBe(201); + expect(APIUsers.post).toHaveBeenCalledWith("membership/create", { + formData: { name: "John Doe" }, + }); + }); + + it("deve retornar dados da filiação com base no status", async () => { + const mockData = [{ id: 1, status: "active" }]; + APIUsers.get.mockResolvedValueOnce({ data: mockData }); + + const result = await getMemberShip("active"); + + expect(result).toEqual(mockData); + expect(APIUsers.get).toHaveBeenCalledWith("membership", { + params: { status: "active" }, + }); + }); + + it("deve retornar dados da filiação pelo ID", async () => { + const mockData = { id: 1, name: "John Doe" }; + APIUsers.get.mockResolvedValueOnce({ data: mockData }); + + const result = await getMemberShipById(1); + + expect(result).toEqual(mockData); + expect(APIUsers.get).toHaveBeenCalledWith("membership/1"); + }); + + it("deve atualizar o status da filiação e retornar dados", async () => { + const mockResponse = { success: true }; + APIUsers.patch.mockResolvedValueOnce({ data: mockResponse }); + + const result = await updateMemberStatus(1, { status: "inactive" }); + + expect(result).toEqual(mockResponse); + expect(APIUsers.patch).toHaveBeenCalledWith("membership/updateStatus/1", { + formData: { status: "inactive" }, + }); + }); + + it("deve retornar false quando atualizar a filiação com sucesso", async () => { + APIUsers.patch.mockResolvedValueOnce({}); + + const result = await updateMembership(1, { name: "John Updated" }); + + expect(result).toBe(false); + expect(APIUsers.patch).toHaveBeenCalledWith("membership/update/1", { + formData: { name: "John Updated" }, + }); + }); + + it("deve retornar false ao deletar a filiação com sucesso", async () => { + APIUsers.delete.mockResolvedValueOnce({}); + + const result = await deleteMember(1); + + expect(result).toBe(false); + expect(APIUsers.delete).toHaveBeenCalledWith("membership/delete/1"); + }); + + it("deve retornar erro ao falhar no createMemberShip", async () => { + const mockError = { response: { data: { erro: "Erro na requisição" } } }; + APIUsers.post.mockRejectedValueOnce(mockError); + + const result = await createMemberShip({ name: "John Doe" }); + + expect(result).toBe("Erro na requisição"); + expect(APIUsers.post).toHaveBeenCalledWith("membership/create", { + formData: { name: "John Doe" }, + }); + }); +}); From 8df43c5c18dec75609b5833f5f6d64a5f3b2d5ce Mon Sep 17 00:00:00 2001 From: Clara Ribeiro Date: Tue, 17 Dec 2024 06:39:47 -0300 Subject: [PATCH 2/4] tests: adiciona testes em componentes --- package-lock.json | 9 +- package.json | 2 +- src/Components/AdvantagesCard/index.test.jsx | 34 ++++++ src/Components/AdvantagesModal/index.test.jsx | 71 ++++++++++++ .../Public/ChangePasswordPage/index.test.jsx | 48 +++++++++ src/Services/memberShipService.test.js | 102 ------------------ 6 files changed, 158 insertions(+), 108 deletions(-) create mode 100644 src/Components/AdvantagesCard/index.test.jsx create mode 100644 src/Components/AdvantagesModal/index.test.jsx create mode 100644 src/Pages/Public/ChangePasswordPage/index.test.jsx delete mode 100644 src/Services/memberShipService.test.js diff --git a/package-lock.json b/package-lock.json index 83bc319..4ed501b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "vitest-sonar-reporter": "^2.0.0" }, "devDependencies": { - "@testing-library/jest-dom": "^6.4.8", + "@testing-library/jest-dom": "^6.6.3", "@testing-library/user-event": "^14.5.2", "@types/react": "^18.2.66", "@types/react-dom": "^18.2.22", @@ -1696,13 +1696,12 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "6.4.8", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.8.tgz", - "integrity": "sha512-JD0G+Zc38f5MBHA4NgxQMR5XtO5Jx9g86jqturNTt2WUfRmLDIY7iKkWHDCCTiDuFMre6nxAD5wHw9W5kI4rGw==", + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz", + "integrity": "sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==", "dev": true, "dependencies": { "@adobe/css-tools": "^4.4.0", - "@babel/runtime": "^7.9.2", "aria-query": "^5.0.0", "chalk": "^3.0.0", "css.escape": "^1.5.1", diff --git a/package.json b/package.json index ec2ec0e..0290754 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "vitest-sonar-reporter": "^2.0.0" }, "devDependencies": { - "@testing-library/jest-dom": "^6.4.8", + "@testing-library/jest-dom": "^6.6.3", "@testing-library/user-event": "^14.5.2", "@types/react": "^18.2.66", "@types/react-dom": "^18.2.22", diff --git a/src/Components/AdvantagesCard/index.test.jsx b/src/Components/AdvantagesCard/index.test.jsx new file mode 100644 index 0000000..f38cd9e --- /dev/null +++ b/src/Components/AdvantagesCard/index.test.jsx @@ -0,0 +1,34 @@ +import "@testing-library/jest-dom"; +import { render, screen, fireEvent } from "@testing-library/react"; +import { describe, it, expect, vi } from "vitest"; +import AdvantagesCard from "./index"; + +describe("AdvantagesCard", () => { + it("should render the title correctly", () => { + const mockTitle = "Benefícios exclusivos"; + + render( {}} />); + + const titleElement = screen.getByText(mockTitle); + expect(titleElement).toBeInTheDocument(); + }); + + it("should call onClick when 'Saber mais' is clicked", () => { + const mockOnClick = vi.fn(); + const mockTitle = "Benefícios exclusivos"; + + render(); + + const linkElement = screen.getByText("Saber mais"); + fireEvent.click(linkElement); + + expect(mockOnClick).toHaveBeenCalled(); + }); + + it("should render without crashing when no props are provided", () => { + render(); + const linkElement = screen.getByText("Saber mais"); + + expect(linkElement).toBeInTheDocument(); + }); +}); diff --git a/src/Components/AdvantagesModal/index.test.jsx b/src/Components/AdvantagesModal/index.test.jsx new file mode 100644 index 0000000..4596c63 --- /dev/null +++ b/src/Components/AdvantagesModal/index.test.jsx @@ -0,0 +1,71 @@ +import "@testing-library/jest-dom"; +import { render, screen, fireEvent } from "@testing-library/react"; +import { describe, it, expect, vi } from "vitest"; +import AdvantagesModal from "./index"; + +describe("AdvantagesModal", () => { + const mockTitle = "Vantagens do Sindicato"; + const mockDescription = "Este é o detalhamento das vantagens oferecidas."; + const mockOnClose = vi.fn(); + + it("should render the title correctly", () => { + render( + + ); + + const titleElement = screen.getByText(mockTitle); + expect(titleElement).toBeInTheDocument(); + }); + + it("should render the description correctly", () => { + render( + + ); + + const descriptionElement = screen.getByText(mockDescription); + expect(descriptionElement).toBeInTheDocument(); + }); + + it("should call onClose when the close button is clicked", () => { + render( + + ); + + const closeButton = screen.getByText("x"); + fireEvent.click(closeButton); + + expect(mockOnClose).toHaveBeenCalledTimes(1); + }); + + it("should render the contact information", () => { + render( + + ); + + const contactInfo = screen.getByText((content) => + content.includes("Para mais informações, entre em contato com o Sindicato pelo número") + ); + + const phoneNumber = screen.getByText("(61) 3321-1949"); + + expect(contactInfo).toBeInTheDocument(); + expect(phoneNumber).toBeInTheDocument(); + }); + +}); diff --git a/src/Pages/Public/ChangePasswordPage/index.test.jsx b/src/Pages/Public/ChangePasswordPage/index.test.jsx new file mode 100644 index 0000000..0acfaf7 --- /dev/null +++ b/src/Pages/Public/ChangePasswordPage/index.test.jsx @@ -0,0 +1,48 @@ +import "@testing-library/jest-dom"; +import { render, screen, waitFor } from "@testing-library/react"; +import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; +import ChangePasswordPage from "./index"; +import { MemoryRouter, Route, Routes } from "react-router-dom"; +import { verifyToken } from "../../../Services/userService"; + +// Mock das funções do userService +vi.mock("../../../Services/userService", () => ({ + verifyToken: vi.fn(), + changePasswordById: vi.fn(), +})); + +describe("ChangePasswordPage", () => { + + const renderComponent = (token) => { + render( + + + } /> + + + ); + }; + + beforeEach(() => { + vi.clearAllMocks(); + vi.spyOn(window, "alert").mockImplementation(() => {}); + }); + + afterEach(() => { + window.alert.mockRestore(); + }); + + it("should render the expired message when the token is invalid", async () => { + verifyToken.mockRejectedValueOnce(new Error("Token inválido")); + + renderComponent("invalid-token"); + + await waitFor(() => { + expect( + screen.getByText("Essa página expirou ou não existe...") + ).toBeInTheDocument(); + }); + + expect(verifyToken).toHaveBeenCalledWith("invalid-token"); + }); +}); \ No newline at end of file diff --git a/src/Services/memberShipService.test.js b/src/Services/memberShipService.test.js deleted file mode 100644 index 01e18f2..0000000 --- a/src/Services/memberShipService.test.js +++ /dev/null @@ -1,102 +0,0 @@ -import { describe, it, expect, vi, beforeEach } from "vitest"; -import { - createMemberShip, - getMemberShip, - getMemberShipById, - updateMemberStatus, - updateMembership, - deleteMember, -} from "./memberShipService"; -import { APIUsers } from "./BaseService"; - -vi.mock("../services/BaseService", () => ({ - APIUsers: { - post: vi.fn(), - get: vi.fn(), - patch: vi.fn(), - delete: vi.fn(), - }, -})); - -describe("MembershipService", () => { - beforeEach(() => { - vi.clearAllMocks(); - }); - - it("deve retornar o status correto ao criar uma filiação", async () => { - APIUsers.post.mockResolvedValueOnce({ status: 201 }); - - const result = await createMemberShip({ name: "John Doe" }); - - expect(result).toBe(201); - expect(APIUsers.post).toHaveBeenCalledWith("membership/create", { - formData: { name: "John Doe" }, - }); - }); - - it("deve retornar dados da filiação com base no status", async () => { - const mockData = [{ id: 1, status: "active" }]; - APIUsers.get.mockResolvedValueOnce({ data: mockData }); - - const result = await getMemberShip("active"); - - expect(result).toEqual(mockData); - expect(APIUsers.get).toHaveBeenCalledWith("membership", { - params: { status: "active" }, - }); - }); - - it("deve retornar dados da filiação pelo ID", async () => { - const mockData = { id: 1, name: "John Doe" }; - APIUsers.get.mockResolvedValueOnce({ data: mockData }); - - const result = await getMemberShipById(1); - - expect(result).toEqual(mockData); - expect(APIUsers.get).toHaveBeenCalledWith("membership/1"); - }); - - it("deve atualizar o status da filiação e retornar dados", async () => { - const mockResponse = { success: true }; - APIUsers.patch.mockResolvedValueOnce({ data: mockResponse }); - - const result = await updateMemberStatus(1, { status: "inactive" }); - - expect(result).toEqual(mockResponse); - expect(APIUsers.patch).toHaveBeenCalledWith("membership/updateStatus/1", { - formData: { status: "inactive" }, - }); - }); - - it("deve retornar false quando atualizar a filiação com sucesso", async () => { - APIUsers.patch.mockResolvedValueOnce({}); - - const result = await updateMembership(1, { name: "John Updated" }); - - expect(result).toBe(false); - expect(APIUsers.patch).toHaveBeenCalledWith("membership/update/1", { - formData: { name: "John Updated" }, - }); - }); - - it("deve retornar false ao deletar a filiação com sucesso", async () => { - APIUsers.delete.mockResolvedValueOnce({}); - - const result = await deleteMember(1); - - expect(result).toBe(false); - expect(APIUsers.delete).toHaveBeenCalledWith("membership/delete/1"); - }); - - it("deve retornar erro ao falhar no createMemberShip", async () => { - const mockError = { response: { data: { erro: "Erro na requisição" } } }; - APIUsers.post.mockRejectedValueOnce(mockError); - - const result = await createMemberShip({ name: "John Doe" }); - - expect(result).toBe("Erro na requisição"); - expect(APIUsers.post).toHaveBeenCalledWith("membership/create", { - formData: { name: "John Doe" }, - }); - }); -}); From 062ba96647ae6afe9ec4fbdf14fb4f3f7ae0ef93 Mon Sep 17 00:00:00 2001 From: Clara Ribeiro Date: Tue, 17 Dec 2024 06:58:12 -0300 Subject: [PATCH 3/4] tests: adiciona testes de rotas --- src/Routes/index.test.jsx | 47 ++++++++++++ src/Routes/permissionProtect.test.jsx | 87 ++++++++++++++++++++++ src/Routes/protectedRoutes.test.jsx | 103 ++++++++++++++++++++++++++ src/Routes/publicRoutes.test.jsx | 89 ++++++++++++++++++++++ 4 files changed, 326 insertions(+) create mode 100644 src/Routes/index.test.jsx create mode 100644 src/Routes/permissionProtect.test.jsx create mode 100644 src/Routes/protectedRoutes.test.jsx create mode 100644 src/Routes/publicRoutes.test.jsx diff --git a/src/Routes/index.test.jsx b/src/Routes/index.test.jsx new file mode 100644 index 0000000..bd34187 --- /dev/null +++ b/src/Routes/index.test.jsx @@ -0,0 +1,47 @@ +import { render, screen } from "@testing-library/react"; +import '@testing-library/jest-dom'; +import { describe, it, expect, vi } from "vitest"; +import Routes from "./index"; +import { AuthProvider } from "../Context/auth"; + +vi.mock("./publicRoutes", () => ({ + default: () =>
Public Routes
, +})); + +vi.mock("./protectedRoutes", () => ({ + default: () =>
Protected Routes
, +})); + +describe("Routes Component", () => { + const renderWithAuth = (user) => { + if (user) { + localStorage.setItem("@App:user", JSON.stringify(user)); + localStorage.setItem("@App:token", JSON.stringify("mockToken")); + } else { + localStorage.removeItem("@App:user"); + localStorage.removeItem("@App:token"); + } + + return render( + + + + ); + }; + + it("should render only PublicRoutes when user is not signed in", () => { + renderWithAuth(null); + + expect(screen.getByText("Public Routes")).toBeInTheDocument(); + expect(screen.queryByText("Protected Routes")).not.toBeInTheDocument(); + }); + + it("should render both ProtectedRoutes and PublicRoutes when user is signed in", () => { + const mockUser = { id: "123", name: "Test User" }; + + renderWithAuth(mockUser); + + expect(screen.getByText("Protected Routes")).toBeInTheDocument(); + expect(screen.getByText("Public Routes")).toBeInTheDocument(); + }); +}); diff --git a/src/Routes/permissionProtect.test.jsx b/src/Routes/permissionProtect.test.jsx new file mode 100644 index 0000000..053ebf2 --- /dev/null +++ b/src/Routes/permissionProtect.test.jsx @@ -0,0 +1,87 @@ +import "@testing-library/jest-dom"; +import { render, screen, waitFor } from "@testing-library/react"; +import { describe, it, expect, vi } from "vitest"; +import PermissionProtect from "./permissionProtect"; +import AuthContext from "../Context/auth"; +import { getRoleById } from "../Services/RoleService/roleService"; +import { checkAction } from "../Utils/permission"; +import { MemoryRouter, Routes, Route } from "react-router-dom"; + +vi.mock("../Services/RoleService/roleService", () => ({ + getRoleById: vi.fn(), +})); + +vi.mock("../Utils/permission", () => ({ + checkAction: vi.fn(), +})); + +describe("PermissionProtect Component", () => { + const mockUser = { + id: "123", + role: "admin", + }; + + const renderComponent = (user, moduleName, actions) => { + return render( + + + + Protected Content} + moduleName={moduleName} + actions={actions} + /> + } + /> + Unauthorized} /> + + + + ); + }; + + it("should render 'Loading...' while fetching permissions", () => { + getRoleById.mockResolvedValueOnce({ permissions: [] }); + + renderComponent(mockUser, "module1", ["read"]); + + expect(screen.getByText("Loading...")).toBeInTheDocument(); + }); + + it("should render the protected element when user has permission", async () => { + getRoleById.mockResolvedValueOnce({ + permissions: [{ module: "module1", actions: ["read"] }], + }); + checkAction.mockReturnValue(true); + + renderComponent(mockUser, "module1", ["read"]); + + await waitFor(() => { + expect(screen.getByText("Protected Content")).toBeInTheDocument(); + }); + }); + + it("should navigate to '/unauthorized' when user does not have permission", async () => { + getRoleById.mockResolvedValueOnce({ + permissions: [{ module: "module1", actions: [] }], + }); + checkAction.mockReturnValue(false); + + renderComponent(mockUser, "module1", ["write"]); + + await waitFor(() => { + expect(screen.getByText("Unauthorized")).toBeInTheDocument(); + }); + }); + + it("should navigate to '/unauthorized' when user role is not defined", async () => { + renderComponent({}, "module1", ["read"]); + + await waitFor(() => { + expect(screen.getByText("Unauthorized")).toBeInTheDocument(); + }); + }); +}); diff --git a/src/Routes/protectedRoutes.test.jsx b/src/Routes/protectedRoutes.test.jsx new file mode 100644 index 0000000..00eb6c6 --- /dev/null +++ b/src/Routes/protectedRoutes.test.jsx @@ -0,0 +1,103 @@ +import "@testing-library/jest-dom"; +import { render, screen, waitFor } from "@testing-library/react"; +import { describe, it, expect, vi, beforeEach } from "vitest"; +import { MemoryRouter, Route, Routes } from "react-router-dom"; +import ProtectedRoutes from "./protectedRoutes"; +import AuthContext from "../Context/auth"; + +vi.mock("./permissionProtect", () => ({ + default: ({ element }) => element, +})); + +vi.mock("../Pages/Protected/Unauthorized", () => ({ + default: () =>
Unauthorized
, +})); + +vi.mock("../Pages/Protected/Home", () => ({ + default: () =>
Home Page
, +})); + +vi.mock("../Pages/Protected/Supplier/CreateSupplier", () => ({ + default: () =>
Create Supplier
, +})); + +vi.mock("../Pages/Protected/Users/userListPage", () => ({ + default: () =>
User List Page
, +})); + +describe("ProtectedRoutes Component", () => { + const mockUser = { + id: "123", + role: "admin", + }; + + const renderProtectedRoutes = (user) => { + return render( + + + + } /> + + + + ); + }; + + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("should render the Home page for the '/home' route", async () => { + renderProtectedRoutes(mockUser); + + await waitFor(() => { + expect(screen.getByText("Home Page")).toBeInTheDocument(); + }); + }); + + it("should render 'Create Supplier' page for '/fornecedores/criar' route", async () => { + render( + + + + } /> + + + + ); + + await waitFor(() => { + expect(screen.getByText("Create Supplier")).toBeInTheDocument(); + }); + }); + + it("should render 'User List Page' for '/usuarios' route", async () => { + render( + + + + } /> + + + + ); + + await waitFor(() => { + expect(screen.getByText("User List Page")).toBeInTheDocument(); + }); + }); + + it("should render 'Unauthorized' page when route is not allowed", async () => { + render( + + + } /> + + + ); + + await waitFor(() => { + expect(screen.getByText("Unauthorized")).toBeInTheDocument(); + }); + }); +}); diff --git a/src/Routes/publicRoutes.test.jsx b/src/Routes/publicRoutes.test.jsx new file mode 100644 index 0000000..bad5631 --- /dev/null +++ b/src/Routes/publicRoutes.test.jsx @@ -0,0 +1,89 @@ +import "@testing-library/jest-dom"; +import { render, screen, waitFor } from "@testing-library/react"; +import { describe, it, expect, vi } from "vitest"; +import { MemoryRouter, Route, Routes } from "react-router-dom"; +import PublicRoutes from "./publicRoutes"; + +vi.mock("../Pages/Public/LoginNovo", () => ({ + default: () =>
Login Page
, +})); + +vi.mock("../Pages/Public/MemberShip", () => ({ + default: () =>
Membership Page
, +})); + +vi.mock("../Pages/Public/PasswordRecovery", () => ({ + default: () =>
Password Recovery Page
, +})); + +vi.mock("../Pages/Public/ChangePasswordPage", () => ({ + default: () =>
Change Password Page
, +})); + +vi.mock("../Pages/Public/VerifyMember/VerifyMemberForm", () => ({ + default: () =>
Verify Member Form
, +})); + +vi.mock("../Pages/Public/VerifyMember/VerifyMemberActiveStatus", () => ({ + default: () =>
Verify Member Active Status
, +})); + +describe("PublicRoutes Component", () => { + const renderPublicRoutes = (initialRoute) => { + return render( + + + } /> + + + ); + }; + + it("should render Login page for the '/' route", async () => { + renderPublicRoutes("/"); + + await waitFor(() => { + expect(screen.getByText("Login Page")).toBeInTheDocument(); + }); + }); + + it("should render Membership page for the '/filiacao' route", async () => { + renderPublicRoutes("/filiacao"); + + await waitFor(() => { + expect(screen.getByText("Membership Page")).toBeInTheDocument(); + }); + }); + + it("should render Password Recovery page for the '/recuperar-senha' route", async () => { + renderPublicRoutes("/recuperar-senha"); + + await waitFor(() => { + expect(screen.getByText("Password Recovery Page")).toBeInTheDocument(); + }); + }); + + it("should render Change Password page for the '/trocar-senha/:token' route", async () => { + renderPublicRoutes("/trocar-senha/mockToken"); + + await waitFor(() => { + expect(screen.getByText("Change Password Page")).toBeInTheDocument(); + }); + }); + + it("should render Verify Member Form for the '/verificar-membro' route", async () => { + renderPublicRoutes("/verificar-membro"); + + await waitFor(() => { + expect(screen.getByText("Verify Member Form")).toBeInTheDocument(); + }); + }); + + it("should render Verify Member Active Status for the '/verificar-membro/ativo' route", async () => { + renderPublicRoutes("/verificar-membro/ativo"); + + await waitFor(() => { + expect(screen.getByText("Verify Member Active Status")).toBeInTheDocument(); + }); + }); +}); From 91437b1c59433f0bf6ce9a6d1cf2cca49b891dc0 Mon Sep 17 00:00:00 2001 From: Clara Ribeiro Date: Tue, 17 Dec 2024 06:59:46 -0300 Subject: [PATCH 4/4] tests: fix prettier --- src/Components/AdvantagesModal/index.test.jsx | 11 ++++++----- src/Pages/Public/ChangePasswordPage/index.test.jsx | 8 +++++--- src/Routes/index.test.jsx | 2 +- src/Routes/publicRoutes.test.jsx | 4 +++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Components/AdvantagesModal/index.test.jsx b/src/Components/AdvantagesModal/index.test.jsx index 4596c63..d9087be 100644 --- a/src/Components/AdvantagesModal/index.test.jsx +++ b/src/Components/AdvantagesModal/index.test.jsx @@ -57,15 +57,16 @@ describe("AdvantagesModal", () => { onClose={mockOnClose} /> ); - + const contactInfo = screen.getByText((content) => - content.includes("Para mais informações, entre em contato com o Sindicato pelo número") + content.includes( + "Para mais informações, entre em contato com o Sindicato pelo número" + ) ); - + const phoneNumber = screen.getByText("(61) 3321-1949"); - + expect(contactInfo).toBeInTheDocument(); expect(phoneNumber).toBeInTheDocument(); }); - }); diff --git a/src/Pages/Public/ChangePasswordPage/index.test.jsx b/src/Pages/Public/ChangePasswordPage/index.test.jsx index 0acfaf7..00992a7 100644 --- a/src/Pages/Public/ChangePasswordPage/index.test.jsx +++ b/src/Pages/Public/ChangePasswordPage/index.test.jsx @@ -12,12 +12,14 @@ vi.mock("../../../Services/userService", () => ({ })); describe("ChangePasswordPage", () => { - const renderComponent = (token) => { render( - } /> + } + /> ); @@ -45,4 +47,4 @@ describe("ChangePasswordPage", () => { expect(verifyToken).toHaveBeenCalledWith("invalid-token"); }); -}); \ No newline at end of file +}); diff --git a/src/Routes/index.test.jsx b/src/Routes/index.test.jsx index bd34187..7fc1b43 100644 --- a/src/Routes/index.test.jsx +++ b/src/Routes/index.test.jsx @@ -1,5 +1,5 @@ import { render, screen } from "@testing-library/react"; -import '@testing-library/jest-dom'; +import "@testing-library/jest-dom"; import { describe, it, expect, vi } from "vitest"; import Routes from "./index"; import { AuthProvider } from "../Context/auth"; diff --git a/src/Routes/publicRoutes.test.jsx b/src/Routes/publicRoutes.test.jsx index bad5631..7503bbe 100644 --- a/src/Routes/publicRoutes.test.jsx +++ b/src/Routes/publicRoutes.test.jsx @@ -83,7 +83,9 @@ describe("PublicRoutes Component", () => { renderPublicRoutes("/verificar-membro/ativo"); await waitFor(() => { - expect(screen.getByText("Verify Member Active Status")).toBeInTheDocument(); + expect( + screen.getByText("Verify Member Active Status") + ).toBeInTheDocument(); }); }); });