Skip to content

Commit 50b4761

Browse files
committed
test(combo-box): add keyboard navigation test
1 parent 5422a61 commit 50b4761

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/ComboBox/ComboBox.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ describe("ComboBox", () => {
6969
expect(screen.getByRole("textbox")).toHaveValue("");
7070
});
7171

72+
it("should handle clear selection via keyboard navigation", async () => {
73+
const consoleLog = vi.spyOn(console, "log");
74+
render(ComboBox, {
75+
props: {
76+
selectedId: "1",
77+
value: "Email",
78+
},
79+
});
80+
81+
const clearButton = screen.getByRole("button", {
82+
name: /clear/i,
83+
});
84+
clearButton.focus();
85+
expect(clearButton).toHaveFocus();
86+
await user.keyboard("{Enter}");
87+
88+
expect(consoleLog).toHaveBeenCalledWith("clear", expect.any(String));
89+
expect(screen.getByRole("textbox")).toHaveValue("");
90+
});
91+
7292
it("should use custom translations when translateWithId is provided", () => {
7393
const customTranslations = {
7494
clearSelection: "Remove selected item",

0 commit comments

Comments
 (0)