(react) react-hook-form Input example

Our form elements needs to be usable with react-hook-form
This commit is contained in:
Romain Le Cellier
2023-07-26 16:52:22 +02:00
parent bdc08cf043
commit b72d0d5c90
5 changed files with 99 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
import { render, screen } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import React, { useRef } from "react";
import userEvent from "@testing-library/user-event";
import { expect } from "vitest";
@@ -160,7 +160,7 @@ describe("<Input/>", () => {
});
expect(input).not.toHaveFocus();
await user.click(screen.getByRole("button", { name: "Focus" }));
expect(input).toHaveFocus();
waitFor(() => expect(input).toHaveFocus());
});
it("works controlled", async () => {
const Wrapper = () => {