Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyf665 committed Nov 4, 2024
1 parent b4a3dca commit 17e849d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/range.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ describe('Picker.Range', () => {
expect(baseElement.querySelector('.rc-picker-dropdown-hidden')).toBeTruthy();
});

it('should not be checked if the value is disabled', () => {
it('should not be checked if the startDate is disabled', () => {
const onChange = jest.fn();
const { container } = render(
<DayRangePicker
Expand All @@ -249,6 +249,24 @@ describe('Picker.Range', () => {
['2024-10-28', '2024-11-21'],
);
});
it('should not be checked if the endDate is disabled', () => {
const onChange = jest.fn();
const { container } = render(
<DayRangePicker
disabled={[false, true]}
defaultValue={[getDay('2024-10-28'), getDay('2024-11-20')]}
disabledDate={(date: Dayjs) => date >= dayjs('2024-11-10').endOf('day')}
onChange={onChange}
/>,
);

openPicker(container, 0);
selectCell('21', 0);
expect(onChange).toHaveBeenCalledWith(
[expect.anything(), expect.anything()],
['2024-10-21', '2024-11-20'],
);
});

it('should close panel when finish first choose with showTime = true and disabled = [false, true]', () => {
const { baseElement } = render(<DayRangePicker showTime disabled={[false, true]} />);
Expand Down

0 comments on commit 17e849d

Please sign in to comment.