mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
test(combo-box): add keyboard navigation test
This commit is contained in:
parent
5422a615bd
commit
50b4761791
1 changed files with 20 additions and 0 deletions
|
@ -69,6 +69,26 @@ describe("ComboBox", () => {
|
||||||
expect(screen.getByRole("textbox")).toHaveValue("");
|
expect(screen.getByRole("textbox")).toHaveValue("");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should handle clear selection via keyboard navigation", async () => {
|
||||||
|
const consoleLog = vi.spyOn(console, "log");
|
||||||
|
render(ComboBox, {
|
||||||
|
props: {
|
||||||
|
selectedId: "1",
|
||||||
|
value: "Email",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const clearButton = screen.getByRole("button", {
|
||||||
|
name: /clear/i,
|
||||||
|
});
|
||||||
|
clearButton.focus();
|
||||||
|
expect(clearButton).toHaveFocus();
|
||||||
|
await user.keyboard("{Enter}");
|
||||||
|
|
||||||
|
expect(consoleLog).toHaveBeenCalledWith("clear", expect.any(String));
|
||||||
|
expect(screen.getByRole("textbox")).toHaveValue("");
|
||||||
|
});
|
||||||
|
|
||||||
it("should use custom translations when translateWithId is provided", () => {
|
it("should use custom translations when translateWithId is provided", () => {
|
||||||
const customTranslations = {
|
const customTranslations = {
|
||||||
clearSelection: "Remove selected item",
|
clearSelection: "Remove selected item",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue