import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import ProductRateFees from "../../../src/pages/lenderSignUp/ProductRateFees";
import { SessionProvider } from "next-auth/react";
import { createTRPCReact } from "@trpc/react-query";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { type AppRouter } from "../../../src/server/trpc/router/_app";
import { trpcConfig } from "../../../src/utils/trpc";
jest.mock("@trpc/client", () => {
return {
httpBatchLink: jest.fn().mockImplementation(() => ({
call: jest.fn(),
})),
loggerLink: jest.fn().mockImplementation(() => ({
call: jest.fn(),
})),
};
});
describe("Describe Product Page", () => {
it("It should render properly", async () => {
const trpc = createTRPCReact<AppRouter>();
const queryClient = new QueryClient();
const trpcClient = trpc.createClient(trpcConfig);
render(
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>
<SessionProvider
session={{
expires: "2100",
user: {
id: "test",
},
}}
>
<ProductRateFees />
</SessionProvider>
</QueryClientProvider>
</trpc.Provider>
);
const header = screen.getByRole("heading");
const headerText = "Sign Up (Admin)";
expect(header).toHaveTextContent(headerText);
});
});