"use strict";

require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
var _DateTimePicker = _interopRequireDefault(require("../DateTimePicker"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } // Note: Tests pass 'locale' because there's no I18nDecorator to provide a value via context and
// otherwise, nothing renders in the label.
describe('DateTimePicker', function () {
  test('should emit an onChange event when changing a component picker', /*#__PURE__*/_asyncToGenerator(function* () {
    var handleChange = jest.fn();
    var user = _userEvent["default"].setup();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      locale: "en-US",
      onChange: handleChange,
      value: new Date(2000, 0, 15, 12, 30)
    }));
    yield user.click(_react.screen.getByLabelText('15 day decrease the value'));
    expect(handleChange).toHaveBeenCalled();
    yield user.click(_react.screen.getByLabelText('12 hour next item'));
    var expected = 2;
    expect(handleChange).toHaveBeenCalledTimes(expected);
  }));
  test('should accept a JavaScript Date for its value prop', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      locale: "en-US",
      value: new Date(2000, 0, 1, 12, 30)
    }));
    var year = _react.screen.getAllByRole('spinbutton')[5];
    var minute = _react.screen.getAllByRole('spinbutton')[1];
    var expectedYear = '2000';
    var expectedMinute = '30';
    expect(year).toHaveTextContent(expectedYear);
    expect(minute).toHaveTextContent(expectedMinute);
  });
  test('should set `dayAriaLabel` to day picker', function () {
    var label = 'custom day aria-label';
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      dayAriaLabel: label,
      locale: "en-US",
      value: new Date(2000, 0, 1, 12, 0)
    }));
    var dayPicker = _react.screen.getByLabelText(label);
    var expected = '1';
    expect(dayPicker).toHaveTextContent(expected);
  });
  test('should set `monthAriaLabel` to month picker', function () {
    var label = 'custom month aria-label';
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      locale: "en-US",
      monthAriaLabel: label,
      value: new Date(2000, 0, 1, 12, 0)
    }));
    var monthPicker = _react.screen.getByLabelText(label);
    var expected = '1';
    expect(monthPicker).toHaveTextContent(expected);
  });
  test('should set `yearAriaLabel` to year picker', function () {
    var label = 'custom year aria-label';
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      locale: "en-US",
      value: new Date(2000, 0, 1, 12, 0),
      yearAriaLabel: label
    }));
    var yearPicker = _react.screen.getByLabelText(label);
    var expected = '2000';
    expect(yearPicker).toHaveTextContent(expected);
  });
  test('should set `hourAriaLabel` to hour picker', function () {
    var label = 'custom hour aria-label';
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      hourAriaLabel: label,
      locale: "en-US",
      value: new Date(2000, 0, 1, 12, 30)
    }));
    var hourPicker = _react.screen.getByLabelText(label);
    var expected = '12';
    expect(hourPicker).toHaveTextContent(expected);
  });
  test('should set `meridiemAriaLabel` to meridiem picker', function () {
    var label = 'custom meridiem aria-label';
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      locale: "en-US",
      meridiemAriaLabel: label,
      value: new Date(2000, 0, 1, 12, 30)
    }));
    var meridiemPicker = _react.screen.getByLabelText(label);
    var expected = 'PM';
    expect(meridiemPicker).toHaveTextContent(expected);
  });
  test('should set `minuteAriaLabel` to minute picker', function () {
    var label = 'custom minute aria-label';
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      locale: "en-US",
      minuteAriaLabel: label,
      value: new Date(2000, 0, 1, 12, 30)
    }));
    var minutePicker = _react.screen.getByLabelText(label);
    var expected = '30';
    expect(minutePicker).toHaveTextContent(expected);
  });
});