Skip to content
Snippets Groups Projects
Unverified Commit 5a8c8f4d authored by Ariya Hidayat's avatar Ariya Hidayat Committed by GitHub
Browse files

When running some TokenField unit tests, shim Element.closest (#17021)

parent de5f8597
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,21 @@ class TokenFieldWithStateAndDefaults extends React.Component {
}
describe("TokenField", () => {
beforeAll(() => {
// temporarily until JSDOM updates
if (!global.Element.prototype.closest) {
global.Element.prototype.closest = function(selector) {
let element = this;
while (element) {
if (element.matches(selector)) {
return element;
}
element = element.parentElement;
}
};
}
});
const input = () => {
return screen.getByRole("textbox");
};
......@@ -142,7 +157,7 @@ describe("TokenField", () => {
/>,
);
userEvent.type(input(), "yep");
expect(input().value).toEqual("");
expect(input().value).toEqual("yep");
type("yep");
expect(input().value).toEqual("yep");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment