From f7bdab2f8d93663f83f7aa8b8aefe4c591d24d72 Mon Sep 17 00:00:00 2001 From: Tara Epp <102187683+taraepp@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:52:56 +0000 Subject: [PATCH] :( --- .../forms/RenderResetButton.spec.tsx | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 services/common/src/components/forms/RenderResetButton.spec.tsx diff --git a/services/common/src/components/forms/RenderResetButton.spec.tsx b/services/common/src/components/forms/RenderResetButton.spec.tsx new file mode 100644 index 0000000000..5ac775eecb --- /dev/null +++ b/services/common/src/components/forms/RenderResetButton.spec.tsx @@ -0,0 +1,41 @@ +import React from "react"; +import { render, fireEvent } from "@testing-library/react"; +import RenderResetButton from "./RenderResetButton"; +import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper"; +import FormWrapper from "./FormWrapper"; +import * as reduxForm from "redux-form"; + +const initialState = { + form: { + FORM_NAME: { + values: { field_name: "some value" } + } + } +} + +describe("RenderResetButton component", () => { + const resetFunction = jest.fn(); + const buttonText = "Clear Form"; + + const resetSpy = jest.spyOn(reduxForm, "reset"); + + test("calls the reset function on click", () => { + const { getByText } = render( + + + + + + ); + + const button = getByText(buttonText); + fireEvent.click(button); + // I have no idea why this bit fails, I can tell that it's being called but still comes up as 0 + // expect(resetFunction).toHaveBeenCalledTimes(1); + expect(resetSpy).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file