2023-06-29 14:18:30 +03:00
|
|
|
import { render, screen } from "@testing-library/react";
|
2023-09-13 17:43:25 +03:00
|
|
|
import { describe, expect, it, vi } from "vitest";
|
2023-06-29 14:18:30 +03:00
|
|
|
|
|
|
|
import { getProcessEnvManager } from "@/lib/helpers/getProcessEnvManager";
|
|
|
|
|
|
|
|
import HomePage from "../page";
|
|
|
|
|
2023-09-13 17:43:25 +03:00
|
|
|
const mockUseSupabase = vi.fn(() => ({
|
|
|
|
session: {
|
|
|
|
user: {},
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
|
|
|
vi.mock("@/lib/context/SupabaseProvider", () => ({
|
|
|
|
useSupabase: () => mockUseSupabase(),
|
|
|
|
}));
|
|
|
|
|
|
|
|
vi.mock("next/navigation", () => ({
|
|
|
|
redirect: (url: string) => url,
|
|
|
|
}));
|
|
|
|
|
2023-06-29 14:18:30 +03:00
|
|
|
describe("HomePage", () => {
|
|
|
|
it("should render HomePage component properly", () => {
|
|
|
|
const { overwriteEnvValuesWith, resetEnvValues } = getProcessEnvManager();
|
|
|
|
|
|
|
|
overwriteEnvValuesWith({
|
|
|
|
NEXT_PUBLIC_ENV: "not-local",
|
|
|
|
});
|
|
|
|
|
|
|
|
render(<HomePage />);
|
|
|
|
const homePage = screen.getByTestId("home-page");
|
|
|
|
expect(homePage).toBeDefined();
|
|
|
|
|
|
|
|
resetEnvValues();
|
|
|
|
});
|
|
|
|
});
|