From ee5b67e9ce54c79d0e95cc936e038cf21c438d49 Mon Sep 17 00:00:00 2001 From: alex-slobodian Date: Tue, 24 Sep 2024 13:19:48 +0300 Subject: [PATCH] Add test for useCertificateViewerDialog hook --- .../useCertificateViewerDialog.test.tsx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/dialogs/certificate-viewer-dialog/useCertificateViewerDialog.test.tsx diff --git a/src/dialogs/certificate-viewer-dialog/useCertificateViewerDialog.test.tsx b/src/dialogs/certificate-viewer-dialog/useCertificateViewerDialog.test.tsx new file mode 100644 index 00000000..229f8d3b --- /dev/null +++ b/src/dialogs/certificate-viewer-dialog/useCertificateViewerDialog.test.tsx @@ -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); + }); +});