"use strict";

var _react = require("@testing-library/react");
var _FormField = _interopRequireDefault(require("./FormField"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
test('affiche le champ et propage les changements', () => {
  const handleChange = jest.fn();
  (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormField.default, {
    label: "Nom",
    name: "nom",
    testId: "nom",
    errorTestId: "nom-error",
    value: "Dupont",
    onChange: handleChange
  }));
  const input = _react.screen.getByTestId('nom');
  expect(input).toHaveValue('Dupont');
  _react.fireEvent.change(input, {
    target: {
      value: 'Martin'
    }
  });
  expect(handleChange).toHaveBeenCalled();
});
test('affiche le message d erreur quand il est fourni', () => {
  (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormField.default, {
    label: "Email",
    name: "email",
    testId: "email",
    errorTestId: "email-error",
    value: "bad",
    error: "email must be a valid email address",
    onChange: () => {}
  }));
  expect(_react.screen.getByTestId('email-error')).toHaveTextContent('email must be a valid email address');
  expect(_react.screen.getByTestId('email-error')).toHaveClass('field-error');
});