Skip to content

Commit

Permalink
Added test to check if the prev month button is redisabled if the pre…
Browse files Browse the repository at this point in the history
…vious month is one before the current month
  • Loading branch information
yulric committed Oct 3, 2015
1 parent 025726c commit 308481a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/date-picker/calendar-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe(`Calendar`, () => {
let initialDate = new Date();
let minDate = new Date(initialDate.toDateString());


let render = TestUtils.renderIntoDocument(
<ThemedCalendar
initialDate={initialDate}
Expand Down Expand Up @@ -65,4 +64,23 @@ describe(`Calendar`, () => {
let calendarToolbar = TestUtils.findRenderedComponentWithType(render, CalendarToolbar);
expect(calendarToolbar.props.prevMonth).to.be.true;
});

it(`should disable the previous month button when the current month is before or the same as the minDate month prop on pressing the prevMonth button`, () => {
let initialDate = new Date();
let minDate = new Date(initialDate.toDateString());
minDate.setMonth(minDate.getMonth() - 1);

let render = TestUtils.renderIntoDocument(
<ThemedCalendar
initialDate={initialDate}
minDate={minDate}
/>
);

let prevMonthIconButton = React.findDOMNode(TestUtils.scryRenderedComponentsWithType(render, IconButton)[0]);
TestUtils.Simulate.touchTap(prevMonthIconButton);

let calendarToolbar = TestUtils.findRenderedComponentWithType(render, CalendarToolbar);
expect(calendarToolbar.props.prevMonth).to.be.false;
});
});

0 comments on commit 308481a

Please sign in to comment.