Skip to content

Commit

Permalink
Add test for useCertificateViewerDialog hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-slobodian committed Aug 6, 2024
1 parent e0d19ac commit dc675d2
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { renderHook, act } from "@testing";
import { useCertificateViewerDialog } from "./useCertificateViewerDialog";
import { CertificateProps } from "../../types";

describe("useCertificateViewerDialog", () => {
it("Should initialize", async () => {
const { result } = renderHook(() => useCertificateViewerDialog());

expect(result.current.dialog).toBeInstanceOf(Function);
expect(result.current.open).toBeInstanceOf(Function);

const certificate = {
id: "1",
label: "Certificate name",
} as CertificateProps;

act(() => {
result.current.open(certificate);
});

const DialogComponent = result.current.dialog();

expect(DialogComponent).not.toBeNull();
expect(DialogComponent?.props.certificate).toBe(certificate);
});
});

0 comments on commit dc675d2

Please sign in to comment.