Skip to content

Instantly share code, notes, and snippets.

@Clarity-89
Created September 15, 2022 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Clarity-89/17b3000136da80e4793ddcc80134433b to your computer and use it in GitHub Desktop.
Save Clarity-89/17b3000136da80e4793ddcc80134433b to your computer and use it in GitHub Desktop.
describe("Form", () => {
it("should save correct data on submit", () => {
const mockSave = jest.fn();
render(<Form saveData={mockSave} />);
fireEvent.change(screen.getByRole("textbox", { name: "Name" }), {
target: { value: "Test" },
});
fireEvent.submit(screen.getByRole("button", { name: "Sign up" }));
expect(mockSave).toHaveBeenLastCalledWith({ ...defaultData, name: "Test" });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment