import { _ as _slicedToArray } from '../../slicedToArray-BB-AwwkK.js';
import React__default, { useState } from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import TextareaField from '../index.js';
import useForm, { Form } from '../../use-form/index.js';
import '../../extends-C4cduGrv.js';
import '../../objectWithoutProperties-TXwlfNxG.js';
import 'prop-types';
import '../../label/index.js';
import '@reach/visually-hidden';
import 'classnames';
import '../../textarea/index.js';
import '../../defineProperty-CEd-kZQW.js';
import '../../stack/index.js';
import '../../ck-icon/index.js';
import '../../ck-icon/assets/icon-map/index.js';
import '../../icon/index.js';
import '@fortawesome/react-fontawesome';
import '../../icon/icons.js';
import '../../icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/pro-solid-svg-icons';
import '@fortawesome/pro-light-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../../text/index.js';
import '../../inline-validation/index.js';
import '../../index-qSfOyGhk.js';
import '../../typeof-CgC7Bq6K.js';
import '../../auto-id.esm-Cly76abB.js';
import '../../utils.esm-CKyxlHOy.js';
import '../../warning-s9zGJbnw.js';
import '../../_commonjsHelpers-_1FafXWI.js';
import '../../use-progress/index.js';
import '../../use-trailing-debounce/index.js';

var ExampleField = function ExampleField() {
  var _useState = useState(""),
      _useState2 = _slicedToArray(_useState, 2),
      value = _useState2[0],
      setvalue = _useState2[1];

  return /*#__PURE__*/React__default.createElement(TextareaField, {
    label: "Description",
    name: "description",
    onChange: function onChange(event) {
      return setvalue(event.target.value);
    },
    value: value
  });
};

var ExampleFieldInForm = function ExampleFieldInForm() {
  var form = useForm({
    initialData: {
      description: ""
    }
  });
  return /*#__PURE__*/React__default.createElement(Form, {
    form: form
  }, /*#__PURE__*/React__default.createElement(TextareaField, {
    label: "Description",
    name: "description"
  }));
};

describe("TextareaField", function () {
  test("using outside of a form", function () {
    render( /*#__PURE__*/React__default.createElement(ExampleField, null));
    var textarea = screen.getByLabelText("Description");
    userEvent.type(textarea, "hello");
    expect(textarea.value).toEqual("hello");
  });
  test("using inside of a form", function () {
    render( /*#__PURE__*/React__default.createElement(ExampleFieldInForm, null));
    var textarea = screen.getByLabelText("Description");
    userEvent.type(textarea, "hello");
    expect(textarea.value).toEqual("hello");
  });
});
