Skip to content

Commit

Permalink
test: add SSR unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
pamapa committed Feb 9, 2024
1 parent 3c8e4c2 commit 0c57e8a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/SSR.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { renderHook } from "@testing-library/react";
import { useAuth } from "../src/useAuth";
import { createWrapper } from "./helpers";

// force Node environment (no window)
jest.unmock("oidc-client-ts");

describe("In a Node SSR environment", () => {
it("auth state is initialised", async () => {
// arrange
const wrapper = createWrapper({
authority: "authority",
client_id: "client",
redirect_uri: "redirect" });

const { result } = renderHook(() => useAuth(), {
wrapper,
});

expect(result.current.isLoading).toBeTruthy();
expect(result.current.isAuthenticated).toBeFalsy();
expect(result.current.user).toBeUndefined();
});
});

0 comments on commit 0c57e8a

Please sign in to comment.