Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl committed Jun 10, 2017
1 parent e0393d5 commit a965511
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions test/daypicker/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('DayPicker’s events handlers', () => {
it('should call the `onCaptionClick` handler', () => {
const handleCaptionClick = spy();
const wrapper = mount(<DayPicker onCaptionClick={handleCaptionClick} />);
wrapper.find('.DayPicker-Caption').simulate('click');
wrapper.find('.DayPicker-Caption').childAt(0).simulate('click');
expect(handleCaptionClick).to.have.been.calledWith(
sinon.match(
date =>
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('DayPicker’s events handlers', () => {
it('should call `onKeyDown` event handler', () => {
const handleKeyDown = spy();
const wrapper = mount(<DayPicker onKeyDown={handleKeyDown} />);
wrapper.simulate('keyDown');
wrapper.childAt(0).simulate('keyDown');
expect(handleKeyDown).to.have.been.calledWith(
sinon.match(e => e instanceof SyntheticEvent && e.target !== null, 'e')
);
Expand All @@ -160,7 +160,7 @@ describe('DayPicker’s events handlers', () => {
const wrapper = mount(
<DayPicker onKeyDown={handleKeyDown} canChangeMonth={false} />
);
wrapper.simulate('keyDown');
wrapper.childAt(0).simulate('keyDown');
expect(handleKeyDown).to.have.been.calledWith(
sinon.match(e => e instanceof SyntheticEvent && e.target !== null, 'e')
);
Expand Down
8 changes: 4 additions & 4 deletions test/daypicker/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,28 @@ describe('DayPicker’s navigation', () => {
it('should call `showNextMonth()` when the RIGHT key is pressed', () => {
const wrapper = mount(<DayPicker />);
const showNextMonth = spy(wrapper.instance(), 'showNextMonth');
wrapper.simulate('keyDown', { keyCode: keys.RIGHT });
wrapper.childAt(0).simulate('keyDown', { keyCode: keys.RIGHT });
expect(showNextMonth).to.have.been.calledOnce;
showNextMonth.restore();
});
it('should call `showPreviousMonth()` when the LEFT key is pressed', () => {
const wrapper = mount(<DayPicker />);
const showPreviousMonth = spy(wrapper.instance(), 'showPreviousMonth');
wrapper.simulate('keyDown', { keyCode: keys.LEFT });
wrapper.childAt(0).simulate('keyDown', { keyCode: keys.LEFT });
expect(showPreviousMonth).to.have.been.calledOnce;
showPreviousMonth.restore();
});
it('should call `showPreviousYear()` when the UP key is pressed', () => {
const wrapper = mount(<DayPicker />);
const showPreviousYear = spy(wrapper.instance(), 'showPreviousYear');
wrapper.simulate('keyDown', { keyCode: keys.UP });
wrapper.childAt(0).simulate('keyDown', { keyCode: keys.UP });
expect(showPreviousYear).to.have.been.calledOnce;
showPreviousYear.restore();
});
it('should call `showNextYear()` when the DOWN key is pressed', () => {
const wrapper = mount(<DayPicker />);
const showNextYear = spy(wrapper.instance(), 'showNextYear');
wrapper.simulate('keyDown', { keyCode: keys.DOWN });
wrapper.childAt(0).simulate('keyDown', { keyCode: keys.DOWN });
expect(showNextYear).to.have.been.calledOnce;
showNextYear.restore();
});
Expand Down
6 changes: 3 additions & 3 deletions test/daypicker/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('DayPicker’s rendering', () => {
});
it('should use the given tabIndex', () => {
const wrapper = shallow(<DayPicker tabIndex={-1} />);
expect(wrapper).to.have.attr('tabindex', '-1');
expect(wrapper.childAt(0)).to.have.attr('tabindex', '-1');
});
it('should spread props to the container', () => {
const wrapper = shallow(
Expand All @@ -123,8 +123,8 @@ describe('DayPicker’s rendering', () => {
const wrapper = mount(
<DayPicker onFocus={handleFocus} onBlur={handleBlur} />
);
wrapper.simulate('focus');
wrapper.simulate('blur');
wrapper.childAt(0).simulate('focus');
wrapper.childAt(0).simulate('blur');
expect(handleBlur).to.have.been.calledOnce;
expect(handleFocus).to.have.been.calledOnce;
});
Expand Down

0 comments on commit a965511

Please sign in to comment.