"use strict";

var _jsxRuntime = require("react/jsx-runtime");

var _enzyme = require("enzyme");

var _DateTimePicker = _interopRequireDefault(require("../DateTimePicker"));

var _DatePickerModule = _interopRequireDefault(require("../../DatePicker/DatePicker.module.css"));

var _TimePickerModule = _interopRequireDefault(require("../../TimePicker/TimePicker.module.css"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

// 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', function () {
    var handleChange = jest.fn();
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      onChange: handleChange,
      value: new Date(2000, 0, 1, 12, 30),
      locale: "en-US"
    }));
    var base = subject.find('DateComponentRangePicker').first();
    base.prop('onChange')({
      value: 0
    });
    var expected = 1;
    var actual = handleChange.mock.calls.length;
    expect(actual).toBe(expected);
  });
  test('should accept a JavaScript Date for its value prop', function () {
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      value: new Date(2000, 0, 1, 12, 30),
      locale: "en-US"
    }));
    var yearPicker = subject.find("DateComponentRangePicker.".concat(_DatePickerModule["default"].year));
    var expectedYear = 2000;
    var actualYear = yearPicker.prop('value');
    expect(actualYear).toBe(expectedYear);
    var minutePicker = subject.find(".".concat(_TimePickerModule["default"].minutePicker)).at(0);
    var expectedMinute = 30;
    var actualMinute = minutePicker.prop('value');
    expect(actualMinute).toBe(expectedMinute);
  });
  test('should set "dayAriaLabel" to day picker', function () {
    var label = 'custom day aria-label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      dayAriaLabel: label,
      value: new Date(2000, 0, 1, 12, 0)
    }));
    var dayPicker = subject.find("DateComponentRangePicker.".concat(_DatePickerModule["default"].day));
    var expected = label;
    var actual = dayPicker.prop('aria-label');
    expect(actual).toBe(expected);
  });
  test('should set "monthAriaLabel" to month picker', function () {
    var label = 'custom month aria-label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      monthAriaLabel: label,
      value: new Date(2000, 0, 1, 12, 0)
    }));
    var monthPicker = subject.find("DateComponentRangePicker.".concat(_DatePickerModule["default"].month));
    var expected = label;
    var actual = monthPicker.prop('aria-label');
    expect(actual).toBe(expected);
  });
  test('should set "yearAriaLabel" to year picker', function () {
    var label = 'custom year aria-label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      value: new Date(2000, 0, 1, 12, 0),
      yearAriaLabel: label
    }));
    var yearPicker = subject.find("DateComponentRangePicker.".concat(_DatePickerModule["default"].year));
    var expected = label;
    var actual = yearPicker.prop('aria-label');
    expect(actual).toBe(expected);
  });
  test('should set "hourAriaLabel" to hour picker', function () {
    var label = 'custom hour aria-label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      hourAriaLabel: label,
      value: new Date(2000, 0, 1, 12, 30)
    }));
    var hourPicker = subject.find(".".concat(_TimePickerModule["default"].hourPicker)).at(0);
    var expected = label;
    var actual = hourPicker.prop('aria-label');
    expect(actual).toBe(expected);
  });
  test('should set "meridiemAriaLabel" to meridiem picker', function () {
    var label = 'custom meridiem aria-label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      meridiemAriaLabel: label,
      value: new Date(2000, 0, 1, 12, 30)
    }));
    var meridiemPicker = subject.find(".".concat(_TimePickerModule["default"].meridiemPicker)).at(0);
    var expected = label;
    var actual = meridiemPicker.prop('aria-label');
    expect(actual).toBe(expected);
  });
  test('should set "minuteAriaLabel" to minute picker', function () {
    var label = 'custom minute aria-label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker["default"], {
      minuteAriaLabel: label,
      value: new Date(2000, 0, 1, 12, 30)
    }));
    var minutePicker = subject.find(".".concat(_TimePickerModule["default"].minutePicker)).at(0);
    var expected = label;
    var actual = minutePicker.prop('aria-label');
    expect(actual).toBe(expected);
  });
});