Skip to content

Commit 17e849d

Browse files
committed
Add test case
1 parent b4a3dca commit 17e849d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/range.spec.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ describe('Picker.Range', () => {
231231
expect(baseElement.querySelector('.rc-picker-dropdown-hidden')).toBeTruthy();
232232
});
233233

234-
it('should not be checked if the value is disabled', () => {
234+
it('should not be checked if the startDate is disabled', () => {
235235
const onChange = jest.fn();
236236
const { container } = render(
237237
<DayRangePicker
@@ -249,6 +249,24 @@ describe('Picker.Range', () => {
249249
['2024-10-28', '2024-11-21'],
250250
);
251251
});
252+
it('should not be checked if the endDate is disabled', () => {
253+
const onChange = jest.fn();
254+
const { container } = render(
255+
<DayRangePicker
256+
disabled={[false, true]}
257+
defaultValue={[getDay('2024-10-28'), getDay('2024-11-20')]}
258+
disabledDate={(date: Dayjs) => date >= dayjs('2024-11-10').endOf('day')}
259+
onChange={onChange}
260+
/>,
261+
);
262+
263+
openPicker(container, 0);
264+
selectCell('21', 0);
265+
expect(onChange).toHaveBeenCalledWith(
266+
[expect.anything(), expect.anything()],
267+
['2024-10-21', '2024-11-20'],
268+
);
269+
});
252270

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

0 commit comments

Comments
 (0)