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 TextField from '../index.js';
import useForm, { Form } from '../../use-form/index.js';
import '../../label/index.js';
import '../../extends-C4cduGrv.js';
import '../../objectWithoutProperties-TXwlfNxG.js';
import 'prop-types';
import '@reach/visually-hidden';
import 'classnames';
import '../../input/index.js';
import '../../defineProperty-CEd-kZQW.js';
import '../../stack/index.js';
import '../../inline-validation/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 '../../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(TextField, {
    label: "Name",
    name: "name",
    onChange: function onChange(event) {
      return setvalue(event.target.value);
    },
    value: value
  });
};

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

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