Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emmayjiang committed Sep 18, 2024
1 parent eeb058d commit 844eea2
Showing 1 changed file with 24 additions and 30 deletions.
54 changes: 24 additions & 30 deletions tests/Modalizer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,29 @@ describe("Modalizer", () => {
.pressTab()
.activeElement((el) => expect(el?.attributes.id).toBe("foo"));
});

it("if trapped, should not escape modalizer if it has no focusables", async () => {
await new BroTest.BroTest(
(
<div {...getTabsterAttribute({ root: {} })}>
<div
id="modal"
aria-label="modal"
{...getTabsterAttribute({
modalizer: { id: "modal", isTrapped: true },
})}
tabIndex={0}
>
Hello
</div>
</div>
)
)
.focusElement('#modal')
.activeElement((el) => expect(el?.textContent).toEqual("Hello"))
.pressTab()
.activeElement((el) => expect(el?.textContent).toEqual("Hello"))
});
});
});

Expand Down Expand Up @@ -2704,33 +2727,4 @@ describe("Modalizer with virtual parents provided by getParent()", () => {
expect(ariaHiddens).toEqual([false, false, true])
);
});
});

describe("Modal with focus trap", () => {
beforeEach(async () => {
await BroTest.bootstrapTabsterPage();
});

it("should not escape modalizer if it has no focusables", async () => {
await new BroTest.BroTest(
(
<div {...getTabsterAttribute({ root: {} })}>
<div
id="modal"
aria-label="modal"
{...getTabsterAttribute({
modalizer: { id: "modal", isTrapped: true },
})}
tabIndex={0}
>
Hello
</div>
</div>
)
)
.focusElement('#modal')
.activeElement((el) => expect(el?.textContent).toEqual("Hello"))
.pressTab()
.activeElement((el) => expect(el?.textContent).toEqual("Hello"))
});
})
});

0 comments on commit 844eea2

Please sign in to comment.