-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'nandorojo/master' into selectMultipleDates
- Loading branch information
Showing
9 changed files
with
151 additions
and
14 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,15 @@ | ||
() => { | ||
const [selectedDates, setSelectedDates] = useState([new Date()]); | ||
const onChange = (dates) => { | ||
setSelectedDates(dates); | ||
}; | ||
return ( | ||
<DatePicker | ||
selectedDates={selectedDates} | ||
selectsMultiple | ||
onChange={onChange} | ||
shouldCloseOnSelect={false} | ||
disabledKeyboardNavigation | ||
/> | ||
); | ||
}; |
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
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
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
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,36 @@ | ||
import React from "react"; | ||
import DatePicker from "../src"; | ||
import { render } from "@testing-library/react"; | ||
|
||
describe("Multiple Dates Selected", function () { | ||
function getDatePicker(extraProps) { | ||
return render( | ||
<DatePicker | ||
selectsMultiple | ||
onChange={() => {}} | ||
shouldCloseOnSelect={false} | ||
disabledKeyboardNavigation | ||
{...extraProps} | ||
/>, | ||
); | ||
} | ||
|
||
it("should handle text format for two selected dates", () => { | ||
const datePicker = getDatePicker({ | ||
selectsMultiple: true, | ||
selectedDates: [new Date("2024/01/01"), new Date("2024/01/15")], | ||
}); | ||
|
||
expect(datePicker.getByRole("textbox").value).toBe("01/01/2024, 01/15/2024"); | ||
}); | ||
|
||
|
||
it("should handle text format for more than two selected dates", () => { | ||
const datePicker = getDatePicker({ | ||
selectsMultiple: true, | ||
selectedDates: [new Date("2024/01/01"), new Date("2024/01/15"), new Date("2024/03/15"), ], | ||
}); | ||
|
||
expect(datePicker.getByRole('textbox').value).toBe("01/01/2024 (+2)"); | ||
}); | ||
}); |