-
-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove
startMonth
and endMonth
default constraints when `dr…
…opdown-months` is set as caption layout (#2648) * examples: add DropdownMonths * refactor: getYearOptions test * feat: remove default startMonth and endMonth for dropdown-months Remove default values when captionLayout equal to dropdown-months. * refactor: Dropdown.test.tsx * chore(test): add DropdownMonths.test.tsx --------- Co-authored-by: Giampaolo Bellavite <[email protected]>
- Loading branch information
Showing
9 changed files
with
407 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
|
||
import { grid, monthDropdown, nextButton } from "@/test/elements"; | ||
import { render } from "@/test/render"; | ||
import { user } from "@/test/user"; | ||
|
||
import { DropdownMonths } from "./DropdownMonths"; | ||
|
||
const today = new Date(2015, 6, 1); | ||
|
||
beforeAll(() => jest.setSystemTime(today)); | ||
afterAll(() => jest.useRealTimers()); | ||
|
||
beforeEach(() => { | ||
render(<DropdownMonths />); | ||
}); | ||
|
||
test("should display the month dropdown", () => { | ||
expect(monthDropdown()).toBeInTheDocument(); | ||
}); | ||
|
||
test("should allow all months", async () => { | ||
expect(grid()).toHaveAccessibleName(`December 2015`); | ||
await user.click(nextButton()); | ||
expect(grid()).toHaveAccessibleName(`January 2016`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from "react"; | ||
|
||
import { DayPicker } from "react-day-picker"; | ||
|
||
export function DropdownMonths() { | ||
const decemberDate = new Date(); | ||
decemberDate.setMonth(11); | ||
|
||
return ( | ||
<DayPicker defaultMonth={decemberDate} captionLayout="dropdown-months" /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.