Skip to content

Commit

Permalink
Add specs for blocked-date recomputation
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Meed committed Aug 8, 2017
1 parent 1c2ddf3 commit 1c854cd
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 11 deletions.
52 changes: 47 additions & 5 deletions test/components/DayPickerRangeController_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -869,14 +869,28 @@ describe('DayPickerRangeController', () => {

describe('blocked-out-of-range', () => {
describe('focusedInput did not change', () => {
it('does not call isOutsideRange', () => {
it('does not call isOutsideRange if unchanged', () => {
const isOutsideRangeStub = sinon.stub();
const wrapper = shallow(<DayPickerRangeController
{...props}
isOutsideRange={isOutsideRangeStub}
/>);
const prevCallCount = isOutsideRangeStub.callCount;
wrapper.instance().componentWillReceiveProps({
...props,
isOutsideRange: isOutsideRangeStub,
});
expect(isOutsideRangeStub.callCount).to.equal(prevCallCount);
});

it('calls isOutsideRange if changed', () => {
const isOutsideRangeStub = sinon.stub();
const wrapper = shallow(<DayPickerRangeController {...props} />);
wrapper.instance().componentWillReceiveProps({
...props,
isOutsideRange: isOutsideRangeStub,
});
expect(isOutsideRangeStub.callCount).to.equal(0);
expect(isOutsideRangeStub.callCount).to.not.equal(0);
});
});

Expand Down Expand Up @@ -939,14 +953,28 @@ describe('DayPickerRangeController', () => {

describe('blocked-calendar', () => {
describe('focusedInput did not change', () => {
it('does not call isDayBlocked', () => {
it('does not call isDayBlocked if unchanged', () => {
const isDayBlockedStub = sinon.stub();
const wrapper = shallow(<DayPickerRangeController
{...props}
isDayBlocked={isDayBlockedStub}
/>);
const prevCallCount = isDayBlockedStub.callCount;
wrapper.instance().componentWillReceiveProps({
...props,
isDayBlocked: isDayBlockedStub,
});
expect(isDayBlockedStub.callCount).to.equal(prevCallCount);
});

it('calls isDayBlocked if changed', () => {
const isDayBlockedStub = sinon.stub();
const wrapper = shallow(<DayPickerRangeController {...props} />);
wrapper.instance().componentWillReceiveProps({
...props,
isDayBlocked: isDayBlockedStub,
});
expect(isDayBlockedStub.callCount).to.equal(0);
expect(isDayBlockedStub.callCount).to.not.equal(0);
});
});

Expand Down Expand Up @@ -1010,13 +1038,27 @@ describe('DayPickerRangeController', () => {
describe('highlighted-calendar', () => {
describe('focusedInput did not change', () => {
it('does not call isDayHighlighted', () => {
const isDayHighlightedStub = sinon.stub();
const wrapper = shallow(<DayPickerRangeController
{...props}
isDayHighlighted={isDayHighlightedStub}
/>);
const prevCallCount = isDayHighlightedStub.callCount;
wrapper.instance().componentWillReceiveProps({
...props,
isDayHighlighted: isDayHighlightedStub,
});
expect(isDayHighlightedStub.callCount).to.equal(prevCallCount);
});

it('calls isDayHighlighted if changed', () => {
const isDayHighlightedStub = sinon.stub();
const wrapper = shallow(<DayPickerRangeController {...props} />);
wrapper.instance().componentWillReceiveProps({
...props,
isDayHighlighted: isDayHighlightedStub,
});
expect(isDayHighlightedStub.callCount).to.equal(0);
expect(isDayHighlightedStub.callCount).to.not.equal(0);
});
});

Expand Down
56 changes: 50 additions & 6 deletions test/components/DayPickerSingleDateController_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,30 @@ describe('DayPickerSingleDateController', () => {

describe('blocked-out-of-range', () => {
describe('props.focused did not change', () => {
it('does not call isOutsideRange', () => {
it('does not call isOutsideRange if unchanged', () => {
const isOutsideRangeStub = sinon.stub();
const wrapper = shallow(
<DayPickerSingleDateController
{...props}
isOutsideRange={isOutsideRangeStub}
/>,
);
const prevCallCount = isOutsideRangeStub.callCount;
wrapper.instance().componentWillReceiveProps({
...props,
isOutsideRange: isOutsideRangeStub,
});
expect(isOutsideRangeStub.callCount).to.equal(prevCallCount);
});

it('calls isOutsideRange if changed', () => {
const isOutsideRangeStub = sinon.stub();
const wrapper = shallow(<DayPickerSingleDateController {...props} />);
wrapper.instance().componentWillReceiveProps({
...props,
isOutsideRange: isOutsideRangeStub,
});
expect(isOutsideRangeStub.callCount).to.equal(0);
expect(isOutsideRangeStub.callCount).to.not.equal(0);
});
});

Expand Down Expand Up @@ -238,14 +254,28 @@ describe('DayPickerSingleDateController', () => {

describe('blocked-calendar', () => {
describe('props.focused did not change', () => {
it('does not call isDayBlocked', () => {
it('does not call isDayBlocked if unchanged', () => {
const isDayBlockedStub = sinon.stub();
const wrapper = shallow(<DayPickerSingleDateController
{...props}
isDayBlocked={isDayBlockedStub}
/>);
const prevCallCount = isDayBlockedStub.callCount;
wrapper.instance().componentWillReceiveProps({
...props,
isDayBlocked: isDayBlockedStub,
});
expect(isDayBlockedStub.callCount).to.equal(prevCallCount);
});

it('calls isDayBlocked if changed', () => {
const isDayBlockedStub = sinon.stub();
const wrapper = shallow(<DayPickerSingleDateController {...props} />);
wrapper.instance().componentWillReceiveProps({
...props,
isDayBlocked: isDayBlockedStub,
});
expect(isDayBlockedStub.callCount).to.equal(0);
expect(isDayBlockedStub.callCount).to.not.equal(0);
});
});

Expand Down Expand Up @@ -308,14 +338,28 @@ describe('DayPickerSingleDateController', () => {

describe('highlighted-calendar', () => {
describe('focusedInput did not change', () => {
it('does not call isDayHighlighted', () => {
it('does not call isDayHighlighted if unchanged', () => {
const isDayHighlightedStub = sinon.stub();
const wrapper = shallow(<DayPickerSingleDateController
{...props}
isDayHighlighted={isDayHighlightedStub}
/>);
const prevCallCount = isDayHighlightedStub.callCount;
wrapper.instance().componentWillReceiveProps({
...props,
isDayHighlighted: isDayHighlightedStub,
});
expect(isDayHighlightedStub.callCount).to.equal(prevCallCount);
});

it('calls isDayHighlighted if changed', () => {
const isDayHighlightedStub = sinon.stub();
const wrapper = shallow(<DayPickerSingleDateController {...props} />);
wrapper.instance().componentWillReceiveProps({
...props,
isDayHighlighted: isDayHighlightedStub,
});
expect(isDayHighlightedStub.callCount).to.equal(0);
expect(isDayHighlightedStub.callCount).to.not.equal(0);
});
});

Expand Down

0 comments on commit 1c854cd

Please sign in to comment.