Skip to content

Commit

Permalink
test: PetList, Logout and ProtectedPage
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsbalazs committed Sep 23, 2024
1 parent de57290 commit 764fb78
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frontend/src/pages/Logout.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import {describe, expect, it, vi} from "vitest";
import { usePetClinicState } from "../state";
import { Logout } from "./Logout";

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/pages/PetList.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChakraProvider } from "@chakra-ui/react";
import { render, screen, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { describe, expect, vi } from "vitest";
import {describe, expect, Mock, test, vi} from "vitest";
import { petList } from "../httpClient";
import { PetList } from "./PetList";

Expand All @@ -25,7 +25,7 @@ const mockPets = {
describe("PetList Component", () => {
test("renders pet list and handles navigation", async () => {
// Arrange
petList.mockResolvedValueOnce(mockPets);
(petList as Mock).mockResolvedValueOnce(mockPets);

render(
<ChakraProvider>
Expand Down Expand Up @@ -53,7 +53,7 @@ describe("PetList Component", () => {

test("displays message when no pets are registered", async () => {
// Arrange
petList.mockResolvedValueOnce({ pets: [] });
(petList as Mock).mockResolvedValueOnce({ pets: [] });

render(
<ChakraProvider>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/pages/utils/ProtectedPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { describe, expect, vi } from "vitest";
import {describe, expect, vi, test} from "vitest";
import { usePetClinicState } from "../../state";
import { ProtectedPage } from "./ProtectedPage";

Expand All @@ -12,7 +12,7 @@ vi.mock("../../state", () => ({
describe("ProtectedPage Component", () => {
test("renders children when user is authenticated", () => {
// Arrange
usePetClinicState.mockReturnValue({
(usePetClinicState as vi.mock).mockReturnValue({
auth: { user: { name: "John Doe" } },
});

Expand All @@ -30,7 +30,7 @@ describe("ProtectedPage Component", () => {

test("renders Login component when user is not authenticated", () => {
// Arrange
usePetClinicState.mockReturnValue({
(usePetClinicState as vi.mock).mockReturnValue({
auth: { user: null },
});

Expand Down

0 comments on commit 764fb78

Please sign in to comment.