Skip to content

Commit

Permalink
fix(date-picker): test
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgarciadev committed May 24, 2024
1 parent 6bbd234 commit 39bc460
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions packages/components/date-picker/__tests__/date-picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ describe("DatePicker", () => {
});
});


describe("Month and Year Picker", () => {
const onHeaderExpandedChangeSpy = jest.fn();

Expand Down Expand Up @@ -576,35 +575,36 @@ describe("DatePicker", () => {
expect(dialog).toBeVisible();
expect(calendarBottomContent).toBeVisible();
});
});
it("should close listbox by clicking another datepicker", async () => {
const {getByRole, getAllByRole} = render(
<>
<DatePicker data-testid="datepicker" label="Date" />
<DatePicker data-testid="datepicker2" label="Date" />
</>,
);

const dateButtons = getAllByRole("button");
it("should close listbox by clicking another datepicker", async () => {
const {getByRole, getAllByRole} = render(
<>
<DatePicker data-testid="datepicker" label="Date" />
<DatePicker data-testid="datepicker2" label="Date" />
</>,
);

const dateButtons = getAllByRole("button");

expect(dateButtons[0]).not.toBeNull();
expect(dateButtons[0]).not.toBeNull();

expect(dateButtons[1]).not.toBeNull();
expect(dateButtons[1]).not.toBeNull();

// open the datepicker dialog by clicking datepicker button in the first datepicker
triggerPress(dateButtons[0]);
// open the datepicker dialog by clicking datepicker button in the first datepicker
triggerPress(dateButtons[0]);

let dialog = getByRole("dialog");
let dialog = getByRole("dialog");

// assert that the first datepicker dialog is open
expect(dialog).toBeVisible();
// assert that the first datepicker dialog is open
expect(dialog).toBeVisible();

// close the datepicker dialog by clicking the second datepicker
triggerPress(dateButtons[1]);
// close the datepicker dialog by clicking the second datepicker
triggerPress(dateButtons[1]);

dialog = getByRole("dialog");
dialog = getByRole("dialog");

// assert that the second datepicker dialog is open
expect(dialog).toBeVisible();
// assert that the second datepicker dialog is open
expect(dialog).toBeVisible();
});
});
});

0 comments on commit 39bc460

Please sign in to comment.