@@ -3,6 +3,7 @@ import moment from 'moment/min/moment-with-locales';
33import { expect } from 'chai' ;
44import sinon from 'sinon-sandbox' ;
55import { mount , shallow } from 'enzyme' ;
6+ import { cloneDeep } from 'lodash' ;
67
78import * as isDayVisible from '../../src/utils/isDayVisible' ;
89import 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