Skip to content

Commit dce9c22

Browse files
majapwljharb
authored andcommitted
Revert "Revert "[Tests] DayPicker: unit test for getWeekHeaders()""
This reverts commit defb7fd.
1 parent ba61165 commit dce9c22

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/components/DayPicker_spec.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import moment from 'moment/min/moment-with-locales';
33
import { expect } from 'chai';
44
import sinon from 'sinon-sandbox';
55
import { mount, shallow } from 'enzyme';
6+
import { cloneDeep } from 'lodash';
67

78
import * as isDayVisible from '../../src/utils/isDayVisible';
89
import isSameMonth from '../../src/utils/isSameMonth';
@@ -1013,6 +1014,23 @@ describe('DayPicker', () => {
10131014
});
10141015
});
10151016

1017+
describe('#getWeekHeaders', () => {
1018+
it('returns unmutated weekday headers for currentMonth in a future', () => {
1019+
sinon.stub(PureDayPicker.prototype, 'render').returns(null);
1020+
1021+
const getWeekHeadersSpy = sinon.spy(PureDayPicker.prototype, 'getWeekHeaders');
1022+
const INITIAL_MONTH = moment().add(2, 'Months').week(3).weekday(3);
1023+
const wrapper = shallow(<DayPicker initialVisibleMonth={() => INITIAL_MONTH} />).dive();
1024+
const instance = wrapper.instance();
1025+
const state = cloneDeep(wrapper.state());
1026+
1027+
expect(instance.getWeekHeaders()).to.be.eql(INITIAL_MONTH.localeData().weekdaysMin());
1028+
expect(instance.state).not.to.equal(state);
1029+
expect(instance.state).to.eql(state);
1030+
expect(getWeekHeadersSpy).to.have.property('callCount', 1);
1031+
});
1032+
});
1033+
10161034
describe('life cycle methods', () => {
10171035
describe.skip('#componentDidMount', () => {
10181036
describe('props.orientation === HORIZONTAL_ORIENTATION', () => {

0 commit comments

Comments
 (0)