Skip to content

Commit c4e00aa

Browse files
committed
maint(pat tabs): Fix test for error not thrown.
Fix an ``UnhandledPromiseRejection`` error with an asynchronous test. The problem popped up in node version 16 and was passing in node version 14.
1 parent 2d799f8 commit c4e00aa

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/pat/tabs/tabs.test.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,19 @@ describe("pat-tabs", function () {
325325
el.innerHTML = "<div></div>";
326326
jest.spyOn(el, "getBoundingClientRect").mockImplementation(() => { return { x: 0, width: 0 }; }); // prettier-ignore
327327

328-
pattern.init(el.querySelector("div"));
329-
await utils.timeout(1);
330-
document.body.dispatchEvent(new Event("pat-update"));
331-
expect(pattern).not.toThrow(TypeError);
328+
let thrown = false;
329+
try {
330+
pattern.init(el.querySelector("div"));
331+
await utils.timeout(1);
332+
document.body.dispatchEvent(new Event("pat-update"));
333+
await utils.timeout(1);
334+
} catch (e) {
335+
if (e instanceof TypeError) {
336+
thrown = true;
337+
} else {
338+
throw e;
339+
}
340+
}
341+
expect(thrown).toBe(false);
332342
});
333343
});

0 commit comments

Comments
 (0)