// import { fireEvent, render, waitFor } from "@testing-library/react";

// import { createForm } from "factory";

describe("createForm [ Validation ]", () => {
  // type SighUpForm = {
  //   user: {
  //     email: string;
  //     password: string;
  //     confirmPassword: string;
  //   };
  // };

  // let formInstance = createForm<SighUpForm>({
  //   user: {
  //     email: "",
  //     password: "",
  //     confirmPassword: "",
  //   },
  // });

  beforeEach(() => {
    // formInstance = createForm<SighUpForm>({
    //   user: {
    //     email: "",
    //     password: "",
    //     confirmPassword: "",
    //   },
    // });
  });

  // describe("when creating functional form", () => {
  //   it("should allow to render fields and submit values", async () => {
  //     const { Form, FormButton } = formInstance;
  //     const onSubmit = jest.fn();

  //     const App = () => {
  //       return (
  //         <Form onSubmit={onSubmit}>
  //           {/* <Field data-testid="user.email" name="user.email" type="text" required />
  //           <Field data-testid="user.password" name="user.password" type="text" required="This is custom text" />
  //           <Field data-testid="user.confirmPassword" name="user.confirmPassword" type="text" /> */}
  //           <FormButton data-testid="submit" type="submit">
  //             Submit
  //           </FormButton>
  //         </Form>
  //       );
  //     };

  //     const { getByTestId } = render(<App />);

  //     const emailInput = getByTestId("user.email");
  //     const passwordInput = getByTestId("user.password");
  //     const confirmPasswordInput = getByTestId("user.confirmPassword");
  //     const submitButton = getByTestId("submit");

  //     expect(emailInput).toBeDefined();
  //     expect(passwordInput).toBeDefined();
  //     expect(confirmPasswordInput).toBeDefined();
  //     expect(submitButton).toBeDefined();

  //     fireEvent.change(emailInput, { target: { value: "" } });
  //     fireEvent.change(passwordInput, { target: { value: "" } });
  //     fireEvent.change(confirmPasswordInput, { target: { value: "" } });
  //     fireEvent.click(submitButton);

  //     await waitFor(() => {
  //       expect(onSubmit).toHaveBeenCalledTimes(0);

  //       expect(formInstance.form.store.getState().errors).toEqual({
  //         "user.email": {
  //           errors: { required: "This field is required" },
  //           type: "required",
  //           message: "This field is required",
  //           valid: false,
  //         },
  //         "user.password": {
  //           errors: { required: "This is custom text" },
  //           type: "required",
  //           message: "This is custom text",
  //           valid: false,
  //         },
  //         "user.confirmPassword": {
  //           errors: {},
  //           type: "none",
  //           message: "",
  //           valid: true,
  //         },
  //       });
  //     });
  //   });
  // });
});
