Skip to content

Commit

Permalink
chore(date-picker): update test
Browse files Browse the repository at this point in the history
  • Loading branch information
chirokas committed Apr 29, 2024
1 parent e7cf05d commit 2e8dafe
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions packages/components/date-picker/__tests__/date-picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,9 @@ describe("DatePicker", () => {
triggerPress(button);

const dialog = getByRole("dialog");

expect(dialog).toBeVisible();

const header = document.querySelector<HTMLButtonElement>(`button[data-slot="header"]`)!;

expect(dialog).toBeVisible();
expect(onHeaderExpandedChangeSpy).not.toHaveBeenCalled();

triggerPress(header);
Expand Down Expand Up @@ -538,5 +536,44 @@ describe("DatePicker", () => {
expect(dialog).not.toBeInTheDocument();
expect(onHeaderExpandedChangeSpy).not.toHaveBeenCalled();
});

it("CalendarBottomContent should render correctly", async () => {
const {getByRole, getByTestId} = render(
<DatePicker
showMonthAndYearPickers
CalendarBottomContent={<div data-testid="calendar-bottom-content" />}
label="Date"
/>,
);

const button = getByRole("button");

triggerPress(button);

let dialog = getByRole("dialog");
let calendarBottomContent = getByTestId("calendar-bottom-content");
const header = document.querySelector<HTMLButtonElement>(`button[data-slot="header"]`)!;

expect(dialog).toBeVisible();
expect(calendarBottomContent).toBeVisible();

triggerPress(header);

expect(dialog).toBeVisible();
expect(calendarBottomContent).not.toBeInTheDocument();

triggerPress(button); // close date picker

expect(dialog).not.toBeInTheDocument();
expect(calendarBottomContent).not.toBeInTheDocument();

triggerPress(button);

dialog = getByRole("dialog");
calendarBottomContent = getByTestId("calendar-bottom-content");

expect(dialog).toBeVisible();
expect(calendarBottomContent).toBeVisible();
});
});
});

0 comments on commit 2e8dafe

Please sign in to comment.