Skip to content

Commit

Permalink
test(combobox): use async expect for non-throwing test case (#11332)
Browse files Browse the repository at this point in the history
**Related Issue:** N/A

## Summary

Adds async assertion to non-throwing test.

## References

* https://vitest.dev/api/expect.html#tothrowerror
* https://vitest.dev/api/expect
* https://jestjs.io/docs/asynchronous#asyncawait
  • Loading branch information
jcfranco authored Jan 20, 2025
1 parent 59ab243 commit 682073f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions packages/calcite-components/src/components/combobox/combobox.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1622,17 +1622,21 @@ describe("calcite-combobox", () => {
});

it("should not throw when typing custom value and pressing ArrowDown", async () => {
const combobox = await page.find("calcite-combobox");
combobox.setProperty("allowCustomValues", true);
await page.waitForChanges();
const inputEl = await page.find(`#myCombobox >>> input`);
await inputEl.focus();
await page.waitForChanges();
expect(await page.evaluate(() => document.activeElement.id)).toBe("myCombobox");
await page.keyboard.type("asdf");
await page.waitForChanges();
await page.keyboard.press("ArrowDown");
await page.waitForChanges();
async function runTest(): Promise<void> {
const combobox = await page.find("calcite-combobox");
combobox.setProperty("allowCustomValues", true);
await page.waitForChanges();
const inputEl = await page.find(`#myCombobox >>> input`);
await inputEl.focus();
await page.waitForChanges();
expect(await page.evaluate(() => document.activeElement.id)).toBe("myCombobox");
await page.keyboard.type("asdf");
await page.waitForChanges();
await page.keyboard.press("ArrowDown");
await page.waitForChanges();
}

await expect(runTest()).resolves.toBeUndefined();
});

it(`ArrowDown opens the item group for combobox in focus and jumps to the first item`, async () => {
Expand Down

0 comments on commit 682073f

Please sign in to comment.