Skip to content

Commit 1c6ea5e

Browse files
committed
Add docs, add unit tests
1 parent d604707 commit 1c6ea5e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Displays a complete, interactive calendar.
9797
|Prop name|Description|Default value|Example values|
9898
|----|----|----|----|
9999
|activeStartDate|The beginning of a period that shall be displayed. If you wish to use React-Calendar in an uncontrolled way, use `defaultActiveStartDate` instead.|(today)|`new Date(2017, 0, 1)`|
100+
|allowPartialRange|Whether to call onChange with only partial result given `selectRange` prop.|`false`|`true`|
100101
|calendarType|Type of calendar that should be used. Can be `"ISO 8601"`, `"US"`, `"Arabic"`, or `"Hebrew"`. Setting to `"US"` or `"Hebrew"` will change the first day of the week to Sunday. Setting to `"Arabic"` will change the first day of the week to Saturday. Setting to `"Arabic"` or `"Hebrew"` will make weekends appear on Friday to Saturday.|Type of calendar most commonly used in a given locale|`"ISO 8601"`|
101102
|className|Class name(s) that will be added along with `"react-calendar"` to the main React-Calendar `<div>` element.|n/a|<ul><li>String: `"class1 class2"`</li><li>Array of strings: `["class1", "class2 class3"]`</li></ul>|
102103
|defaultActiveStartDate|The beginning of a period that shall be displayed by default. If you wish to use React-Calendar in a controlled way, use `activeStartDate` instead.|(today)|`new Date(2017, 0, 1)`|

src/Calendar.spec.jsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,23 @@ describe('Calendar', () => {
743743
expect(onChange).not.toHaveBeenCalled();
744744
});
745745

746-
it('does not call onChange function returning a range when selected one piece of a range given allowPartialRange prop', () => {
746+
it('does not call onChange function returning a range when selected one piece of a range given allowPartialRange = false', () => {
747+
const onChange = jest.fn();
748+
const component = shallow(
749+
<Calendar
750+
allowPartialRange={false}
751+
onChange={onChange}
752+
selectRange
753+
view="month"
754+
/>,
755+
);
756+
757+
component.instance().onChange(new Date(2018, 0, 1));
758+
759+
expect(onChange).not.toHaveBeenCalled();
760+
});
761+
762+
it('calls onChange function returning a partial range when selected one piece of a range given allowPartialRange = true', () => {
747763
const onChange = jest.fn();
748764
const component = shallow(
749765
<Calendar

0 commit comments

Comments
 (0)