diff --git a/src/Calendar.spec.jsx b/src/Calendar.spec.jsx index ba792ee7..7f50e492 100644 --- a/src/Calendar.spec.jsx +++ b/src/Calendar.spec.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount, shallow } from 'enzyme'; +import { shallow } from 'enzyme'; import { getMonthStart } from '@wojtekmaj/date-utils'; import Calendar from './Calendar'; @@ -47,7 +47,7 @@ describe('Calendar', () => { }); it('renders YearView when given view = "year"', () => { - const component = mount( + const component = shallow( , ); @@ -57,7 +57,7 @@ describe('Calendar', () => { }); it('renders DecadeView when given view = "decade"', () => { - const component = mount( + const component = shallow( , ); @@ -67,7 +67,7 @@ describe('Calendar', () => { }); it('renders CenturyView when given view = "century"', () => { - const component = mount( + const component = shallow( , ); @@ -253,11 +253,12 @@ describe('Calendar', () => { describe('handles drill up properly', () => { it('drills up when allowed', () => { - const component = mount( + const component = shallow( , ); component.instance().drillUp(); + component.update(); expect(component.state().view).toBe('year'); }); @@ -265,7 +266,7 @@ describe('Calendar', () => { it('calls onDrillUp on drill up', () => { const onDrillUp = jest.fn(); - const component = mount( + const component = shallow( { it('refuses to drill up when already on minimum allowed detail', () => { const onDrillUp = jest.fn(); - const component = mount( + const component = shallow( { describe('handles drill down properly', () => { it('drills down when allowed', () => { - const component = mount( + const component = shallow( , ); @@ -311,7 +312,7 @@ describe('Calendar', () => { it('calls onDrillDown on drill down', () => { const onDrillDown = jest.fn(); - const component = mount( + const component = shallow( { it('refuses to drill down when already on minimum allowed detail', () => { const onDrillDown = jest.fn(); - const component = mount( + const component = shallow( { describe('handles active start date change properly', () => { it('changes active start date when allowed', () => { - const component = mount( + const component = shallow( , ); component.instance().setActiveStartDate(new Date(2019, 0, 1)); + component.update(); + + const monthView = component.find('MonthView'); - expect(component.state().activeStartDate).toEqual(new Date(2019, 0, 1)); + expect(monthView.prop('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( + const component = shallow( { describe('calls onChange properly', () => { it('calls onChange function returning the beginning of selected period by default', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning the beginning of the selected period when returnValue is set to "start"', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning the beginning of the selected period when returnValue is set to "start"', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning the end of the selected period when returnValue is set to "end"', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning the beginning of selected period when returnValue is set to "range"', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning the beginning of selected period, but no earlier than minDate', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning the beginning of selected period, but no later than maxDate', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning the end of selected period, but no earlier than minDate', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning the end of selected period, but no later than maxDate', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning a range when selected two pieces of a range', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('calls onChange function returning a range when selected reversed two pieces of a range', () => { const onChange = jest.fn(); - const component = mount( + const component = shallow( { it('changes Calendar view given new activeStartDate value', () => { const activeStartDate = new Date(2017, 0, 1); const newActiveStartDate = new Date(2018, 0, 1); - const component = mount( + const component = shallow( , ); component.setProps({ activeStartDate: newActiveStartDate }); + component.update(); const monthView = component.find('MonthView');