"use strict";

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

var _enzyme = require("enzyme");

var _DatePicker = _interopRequireDefault(require("../DatePicker"));

var _DatePickerModule = _interopRequireDefault(require("../DatePicker.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('DatePicker', 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)(_DatePicker["default"], {
      onChange: handleChange,
      value: new Date(2000, 6, 15),
      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)(_DatePicker["default"], {
      value: new Date(2000, 0, 1),
      locale: "en-US"
    }));
    var yearPicker = subject.find("DateComponentRangePicker.".concat(_DatePickerModule["default"].year));
    var expected = 2000;
    var actual = yearPicker.prop('value');
    expect(actual).toBe(expected);
  });
  test('should set "dayAriaLabel" to day picker', function () {
    var label = 'custom day aria-label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker["default"], {
      dayAriaLabel: label,
      value: new Date(2000, 0, 1)
    }));
    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)(_DatePicker["default"], {
      monthAriaLabel: label,
      value: new Date(2000, 0, 1)
    }));
    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)(_DatePicker["default"], {
      value: new Date(2000, 0, 1),
      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 "monthAriaLabel" to month picker', function () {
    var label = 'custom month label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker["default"], {
      monthAriaLabel: label,
      value: new Date(2000, 0, 1)
    }));
    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 label';
    var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker["default"], {
      value: new Date(2000, 0, 1),
      yearAriaLabel: label
    }));
    var yearPicker = subject.find("DateComponentRangePicker.".concat(_DatePickerModule["default"].year));
    var expected = label;
    var actual = yearPicker.prop('aria-label');
    expect(actual).toBe(expected);
  });
});