From a965511052fe30358a8bd4d1450e513c89316853 Mon Sep 17 00:00:00 2001 From: Giampaolo Bellavite Date: Sat, 10 Jun 2017 16:25:44 -0500 Subject: [PATCH] Update unit tests --- test/daypicker/events.js | 6 +++--- test/daypicker/navigation.js | 8 ++++---- test/daypicker/rendering.js | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/daypicker/events.js b/test/daypicker/events.js index e0cb06c405..734c55b27c 100644 --- a/test/daypicker/events.js +++ b/test/daypicker/events.js @@ -13,7 +13,7 @@ describe('DayPicker’s events handlers', () => { it('should call the `onCaptionClick` handler', () => { const handleCaptionClick = spy(); const wrapper = mount(); - wrapper.find('.DayPicker-Caption').simulate('click'); + wrapper.find('.DayPicker-Caption').childAt(0).simulate('click'); expect(handleCaptionClick).to.have.been.calledWith( sinon.match( date => @@ -150,7 +150,7 @@ describe('DayPicker’s events handlers', () => { it('should call `onKeyDown` event handler', () => { const handleKeyDown = spy(); const wrapper = mount(); - wrapper.simulate('keyDown'); + wrapper.childAt(0).simulate('keyDown'); expect(handleKeyDown).to.have.been.calledWith( sinon.match(e => e instanceof SyntheticEvent && e.target !== null, 'e') ); @@ -160,7 +160,7 @@ describe('DayPicker’s events handlers', () => { const wrapper = mount( ); - wrapper.simulate('keyDown'); + wrapper.childAt(0).simulate('keyDown'); expect(handleKeyDown).to.have.been.calledWith( sinon.match(e => e instanceof SyntheticEvent && e.target !== null, 'e') ); diff --git a/test/daypicker/navigation.js b/test/daypicker/navigation.js index f73e8d3bcd..7ead4ab013 100644 --- a/test/daypicker/navigation.js +++ b/test/daypicker/navigation.js @@ -97,28 +97,28 @@ describe('DayPicker’s navigation', () => { it('should call `showNextMonth()` when the RIGHT key is pressed', () => { const wrapper = mount(); 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(); 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(); 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(); 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(); }); diff --git a/test/daypicker/rendering.js b/test/daypicker/rendering.js index 2c48cc1849..2788d442f9 100644 --- a/test/daypicker/rendering.js +++ b/test/daypicker/rendering.js @@ -109,7 +109,7 @@ describe('DayPicker’s rendering', () => { }); it('should use the given tabIndex', () => { const wrapper = shallow(); - 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( @@ -123,8 +123,8 @@ describe('DayPicker’s rendering', () => { const wrapper = mount( ); - 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; });