diff --git a/src/Calendar.spec.jsx b/src/Calendar.spec.jsx index f51fc3eb..ba792ee7 100644 --- a/src/Calendar.spec.jsx +++ b/src/Calendar.spec.jsx @@ -343,6 +343,38 @@ describe('Calendar', () => { }); }); + describe('handles active start date change properly', () => { + it('changes active start date when allowed', () => { + const component = mount( + , + ); + + component.instance().setActiveStartDate(new Date(2019, 0, 1)); + + expect(component.state().activeStartDate).toEqual(new Date(2019, 0, 1)); + }); + + it('calls onActiveStartDateChange on activeStartDate change', () => { + const activeStartDate = new Date(2017, 0, 1); + const newActiveStartDate = new Date(2018, 0, 1); + const onActiveStartDateChange = jest.fn(); + const component = mount( + , + ); + + component.instance().setActiveStartDate(newActiveStartDate); + + expect(onActiveStartDateChange).toHaveBeenCalledWith({ + activeStartDate: newActiveStartDate, + view: 'year', + }); + }); + }); + describe('calls onChange properly', () => { it('calls onChange function returning the beginning of selected period by default', () => { const onChange = jest.fn(); @@ -526,26 +558,6 @@ describe('Calendar', () => { }); }); - it('calls onActiveStartDateChange on activeStartDate change', () => { - const activeStartDate = new Date(2017, 0, 1); - const newActiveStartDate = new Date(2018, 0, 1); - const onActiveStartDateChange = jest.fn(); - const component = mount( - , - ); - - component.instance().setActiveStartDate(newActiveStartDate); - - expect(onActiveStartDateChange).toHaveBeenCalledWith({ - activeStartDate: newActiveStartDate, - view: 'year', - }); - }); - it('changes Calendar view given new activeStartDate value', () => { const activeStartDate = new Date(2017, 0, 1); const newActiveStartDate = new Date(2018, 0, 1);