{"size": 6669, "ext": "js", "max_stars_repo_path": "node_modules/react-date-picker/dist/DateInput/__tests__/MonthSelect.js", "max_stars_repo_name": "blackalkane/NBA-Connect", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/react-date-picker/dist/DateInput/__tests__/MonthSelect.js", "max_issues_repo_name": "blackalkane/NBA-Connect", "max_issues_repo_issues_event_min_datetime": "2020-01-08T00:35:25.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-11T22:46:35.000Z", "max_forks_repo_path": "node_modules/react-date-picker/dist/DateInput/__tests__/MonthSelect.js", "max_forks_repo_name": "blackalkane/NBA-Connect", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 43.5882352941, "max_line_length": 317, "alphanum_fraction": 0.6560203929}
"use strict";

var _react = _interopRequireDefault(require("react"));

var _enzyme = require("enzyme");

var _MonthSelect = _interopRequireDefault(require("../MonthSelect"));

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

/* eslint-disable comma-dangle */
describe('MonthSelect', function () {
  var defaultProps = {
    className: 'className',
    onChange: function onChange() {}
  };
  it('renders a select', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], defaultProps));
    var select = component.find('select');
    var options = select.find('option');
    expect(select).toHaveLength(1);
    expect(options).toHaveLength(13); // 12 months + empty option
  });
  it('applies given aria-label properly', function () {
    var monthAriaLabel = 'Month';
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      monthAriaLabel: monthAriaLabel
    })));
    var select = component.find('select');
    expect(select.prop('aria-label')).toBe(monthAriaLabel);
  });
  it('has proper name defined', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], defaultProps));
    var select = component.find('select');
    expect(select.prop('name')).toBe('month');
  });
  it('has proper className defined', function () {
    var className = 'react-date-picker';
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      className: className
    })));
    var select = component.find('select');
    expect(select.hasClass('react-date-picker__input')).toBe(true);
    expect(select.hasClass('react-date-picker__month')).toBe(true);
  });
  it('displays given value properly', function () {
    var value = 11;
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      value: value
    })));
    var select = component.find('select');
    expect(select.prop('value')).toBe(value);
  });
  it('does not disable select by default', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], defaultProps));
    var select = component.find('select');
    expect(select.prop('disabled')).toBeFalsy();
  });
  it('disables select given disabled flag', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      disabled: true
    })));
    var select = component.find('select');
    expect(select.prop('disabled')).toBeTruthy();
  });
  it('is not required select by default', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], defaultProps));
    var select = component.find('select');
    expect(select.prop('required')).toBeFalsy();
  });
  it('required select given required flag', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      required: true
    })));
    var select = component.find('select');
    expect(select.prop('required')).toBeTruthy();
  });
  it('calls itemRef properly', function () {
    var itemRef = jest.fn();
    (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      itemRef: itemRef
    })));
    expect(itemRef).toHaveBeenCalled();
    expect(itemRef).toHaveBeenCalledWith(expect.any(HTMLSelectElement), 'month');
  });
  it('has all options enabled by default', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], defaultProps));
    var select = component.find('select');
    var options = select.find('option');
    options.forEach(function (option) {
      expect(option.prop('disabled')).toBeFalsy();
    });
  });
  it('has all options enabled given minDate in a past year', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      year: 2018,
      minDate: new Date(2017, 6, 1)
    })));
    var select = component.find('select');
    var options = select.find('option[value]');
    options.forEach(function (option) {
      expect(option.prop('disabled')).toBeFalsy();
    });
  });
  it('has first (month in minDate) options disabled given minDate in a current year', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      year: 2018,
      minDate: new Date(2018, 6, 1)
    })));
    var select = component.find('select');
    var options = select.find('option').slice(1); // Getting rid of "--" option
    // January - June

    options.slice(0, 6).forEach(function (option) {
      expect(option.prop('disabled')).toBeTruthy();
    }); // July - December

    options.slice(6).forEach(function (option) {
      expect(option.prop('disabled')).toBeFalsy();
    });
  });
  it('has all options enabled given maxDate in a future year', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      year: 2018,
      maxDate: new Date(2019, 6, 1)
    })));
    var select = component.find('select');
    var options = select.find('option').slice(1); // Getting rid of "--" option

    options.forEach(function (option) {
      expect(option.prop('disabled')).toBeFalsy();
    });
  });
  it('has last (month in maxDate) options disabled given maxDate in a current year', function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_MonthSelect["default"], _extends({}, defaultProps, {
      year: 2018,
      maxDate: new Date(2018, 6, 1)
    })));
    var select = component.find('select');
    var options = select.find('option').slice(1); // Getting rid of "--" option
    // January - July

    options.slice(0, 7).forEach(function (option) {
      expect(option.prop('disabled')).toBeFalsy();
    }); // August - December

    options.slice(7).forEach(function (option) {
      expect(option.prop('disabled')).toBeTruthy();
    });
  });
});