Skip to content

Commit

Permalink
test: add test code about date clear issue in date picker
Browse files Browse the repository at this point in the history
  • Loading branch information
KumJungMin committed May 27, 2024
1 parent 4ef3a89 commit ac31e00
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/components/date-picker/__tests__/date-picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,5 +457,29 @@ describe("DatePicker", () => {
expect(onChange).toHaveBeenCalledWith(new CalendarDate(2019, 2, 4));
expect(getTextValue(combobox)).toBe("2/4/2019"); // uncontrolled
});

it("should keep the selected date when the picker is toggled, in showMonthAndYearPickers mode", function () {
const {getByRole, getAllByRole} = render(
<DatePicker showMonthAndYearPickers label="Date" value={new CalendarDate(2024, 5, 1)} />,
);

let combobox = getAllByRole("group")[0];

expect(getTextValue(combobox)).toBe("5/1/2024");

let button = getByRole("button");

triggerPress(button);

let dialog = getByRole("dialog");

expect(dialog).toBeVisible();

triggerPress(button);

expect(dialog).not.toBeVisible();

expect(getTextValue(combobox)).toBe("5/1/2024");
});
});
});

0 comments on commit ac31e00

Please sign in to comment.