"use strict";

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

var _enzyme = require("enzyme");

var _TimePicker = _interopRequireDefault(require("../TimePicker"));

var _TimePickerModule = _interopRequireDefault(require("../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('TimePicker', function () {
  // Suite-wide setup
  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)(_TimePicker["default"], {
      onChange: handleChange,
      value: new Date(2000, 6, 15, 3, 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)(_TimePicker["default"], {
      value: new Date(2000, 0, 1, 12, 30),
      locale: "en-US"
    }));
    var minutePicker = subject.find(".".concat(_TimePickerModule["default"].minutePicker)).at(0);
    var expected = 30;
    var actual = minutePicker.prop('value');
    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)(_TimePicker["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)(_TimePicker["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)(_TimePicker["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);
  });
});