"use strict";

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

var _enzyme = require("enzyme");

var _sinon = _interopRequireDefault(require("sinon"));

var _DaySelector = _interopRequireDefault(require("../DaySelector"));

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

var tap = function tap(node) {
  node.simulate('mousedown');
  node.simulate('mouseup');
};

describe('DaySelector', function () {
  it('should set selected prop to true for the item that is selected by default', function () {
    var subject = (0, _enzyme.mount)(_react.default.createElement(_DaySelector.default, {
      defaultSelected: 0
    }));
    var item = subject.find('DaySelectorItem').first();
    var expected = true;
    var actual = item.prop('selected');
    expect(actual).to.equal(expected);
  });
  it('should fire onSelect when a day is selected', function () {
    var handleSelect = _sinon.default.spy();

    var subject = (0, _enzyme.mount)(_react.default.createElement(_DaySelector.default, {
      onSelect: handleSelect
    }));
    var item = subject.find('DaySelectorItem').first();
    tap(item);
    var expected = true;
    var actual = handleSelect.calledOnce;
    expect(actual).to.equal(expected);
  });
  it('should fire onSelect with the correct content when a day is selected', function () {
    var handleSelect = _sinon.default.spy();

    var content = 'Sat';
    var subject = (0, _enzyme.mount)(_react.default.createElement(_DaySelector.default, {
      onSelect: handleSelect
    }));
    var item = subject.find('DaySelectorItem').last();
    tap(item);
    var expected = content;
    var actual = handleSelect.firstCall.args[0].content;
    expect(actual).to.equal(expected);
  });
  it('should use the full string format when dayNameLength is `full`', function () {
    var handleSelect = _sinon.default.spy();

    var content = 'Saturday';
    var subject = (0, _enzyme.mount)(_react.default.createElement(_DaySelector.default, {
      dayNameLength: "full",
      onSelect: handleSelect
    }));
    var item = subject.find('DaySelectorItem').last();
    tap(item);
    var expected = content;
    var actual = handleSelect.firstCall.args[0].content;
    expect(actual).to.equal(expected);
  });
  it('should set selected content as Every day when every day is selected', function () {
    var handleSelect = _sinon.default.spy();

    var content = 'Every Day';
    var subject = (0, _enzyme.mount)(_react.default.createElement(_DaySelector.default, {
      defaultSelected: [0, 1, 2, 3, 4, 5],
      onSelect: handleSelect
    }));
    var item = subject.find('DaySelectorItem').last();
    tap(item);
    var expected = content;
    var actual = handleSelect.firstCall.args[0].content;
    expect(actual).to.equal(expected);
  });
  it('should set selected content as Every weekday when every weekday is selected', function () {
    var handleSelect = _sinon.default.spy();

    var content = 'Every Weekday';
    var subject = (0, _enzyme.mount)(_react.default.createElement(_DaySelector.default, {
      defaultSelected: [0, 1, 2, 3, 4, 5],
      onSelect: handleSelect
    }));
    var item = subject.find('DaySelectorItem').first();
    tap(item);
    var expected = content;
    var actual = handleSelect.firstCall.args[0].content;
    expect(actual).to.equal(expected);
  });
  it('should set selected content as Every weekend when every weekend is selected', function () {
    var handleSelect = _sinon.default.spy();

    var content = 'Every Weekend';
    var subject = (0, _enzyme.mount)(_react.default.createElement(_DaySelector.default, {
      defaultSelected: [0],
      onSelect: handleSelect
    }));
    var item = subject.find('DaySelectorItem').last();
    tap(item);
    var expected = content;
    var actual = handleSelect.firstCall.args[0].content;
    expect(actual).to.equal(expected);
  });
});