import { _ as _asyncToGenerator, r as regenerator } from '../../index-qSfOyGhk.js';
import { _ as _slicedToArray } from '../../slicedToArray-BB-AwwkK.js';
import React__default, { useState } from 'react';
import { render, screen, act } 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 '../../typeof-CgC7Bq6K.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 '../../index-CMfVNfTW.js';
import '../../toConsumableArray-dKQYsfpV.js';
import 'react-dom';
import '../../icon/assets/icon-map/index.js';
import '../../social-icon/index.js';
import '@fortawesome/react-fontawesome';
import '../../social-icon/icons.js';
import '../../social-icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/free-solid-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../../tooltip/index.js';
import '../../auto-id.esm-CjaDlg7r.js';
import '../../utils.esm-BKUEBdyY.js';
import '../../warning-s9zGJbnw.js';
import '../../portal.esm-D9LQ40g_.js';
import '../../portal/index.js';
import '../../use-rerender-once/index.js';
import '../../use-force-update/index.js';
import '../../button/button-group.js';
import '../../inject-css-BqVV5N0s.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", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
    var input;
    return regenerator.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            render( /*#__PURE__*/React__default.createElement(ExampleField, null));
            input = screen.getByLabelText("Name");
            _context.next = 4;
            return act(function () {
              return userEvent.type(input, "ConvertKit");
            });

          case 4:
            expect(input.value).toEqual("ConvertKit");

          case 5:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  })));
  test("using inside of a form", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
    var input;
    return regenerator.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            render( /*#__PURE__*/React__default.createElement(ExampleFieldInForm, null));
            input = screen.getByLabelText("Name");
            _context2.next = 4;
            return act(function () {
              return userEvent.type(input, "ConvertKit");
            });

          case 4:
            expect(input.value).toEqual("ConvertKit");

          case 5:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  })));
});
