Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Incorrect selection of years on right side when clicking throu… #4066

Merged
merged 2 commits into from
Apr 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added unit-test
  • Loading branch information
Sergey Chopchyts authored and Sergey Chopchyts committed Apr 21, 2020
commit 77b3bf2f1de84d5f7a519fc85459418835c75e14
18 changes: 18 additions & 0 deletions packages/datetime/test/dateRangePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,24 @@ describe("<DateRangePicker>", () => {
left.assertMonthYear(Months.JANUARY, 2016);
right.assertMonthYear(Months.FEBRUARY, 2016);
});

it("custom shortcuts set the displayed dates correctly when month stays the same but not years and contiguousCalendarMonths is false", () => {
const dateRange = [new Date(2014, Months.JUNE, 1), new Date(2015, Months.JUNE, 1)] as DateRange;
const { clickShortcut, left, right } = render({
contiguousCalendarMonths: false,
initialMonth: new Date(2015, Months.JUNE, 1),
shortcuts: [{ label: "custom shortcut", dateRange }],
});

clickShortcut();
assert.isTrue(onChangeSpy.calledOnce);
left.assertMonthYear(Months.JUNE, 2014);
right.assertMonthYear(Months.JUNE, 2015);

clickShortcut();
left.assertMonthYear(Months.JUNE, 2014);
right.assertMonthYear(Months.JUNE, 2015);
});
});

describe("when uncontrolled", () => {
Expand Down