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 Sep 24, 2024
1 parent 1ec9381 commit ee5b67e
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { renderHook, act } from "@testing";
import { useCertificateViewerDialog } from "./useCertificateViewerDialog";
import { CertificateProps } from "../../types";

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

expect(result.current.dialog).toBeInstanceOf(Function);
expect(result.current.open).toBeInstanceOf(Function);
expect(result.current.close).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 ee5b67e

Please sign in to comment.