import React from "react";
import "@testing-library/jest-dom/extend-expect";
import { render, fireEvent } from "@testing-library/react";
import { Textarea } from "../../";
test("Textarea basic props", () => {
const onChange = jest.fn();
const onBlur = jest.fn();
const { getByTestId, queryByTestId } = render(
);
const textarea = getByTestId("input1");
expect(textarea).toBeTruthy();
expect(textarea).toHaveTextContent("100");
expect(onChange).toBeCalledTimes(0);
fireEvent.change(textarea, { target: { value: "test" } });
expect(onChange).toBeCalledTimes(1);
expect(onChange).toHaveBeenLastCalledWith("test");
expect(onBlur).toBeCalledTimes(0);
fireEvent.blur(textarea);
expect(onBlur).toBeCalledTimes(1);
expect(getByTestId("input1")).not.toHaveClass("is-invalid");
expect(queryByTestId("input1-error")).toBeNull();
expect(queryByTestId("input1-help")).toBeNull();
expect(getByTestId("input1").getAttribute("readonly")).toBeNull();
expect(getByTestId("input1").getAttribute("disabled")).toBeNull();
expect(getByTestId("input1")).toHaveClass("my-class-name");
});
test("should show default testid", () => {
const { queryByTestId } = render(