Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz committed Apr 13, 2022
1 parent 5254a1e commit cef7aab
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions packages/ariakit/src/combobox/__examples__/combobox-group/test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { getByRole, getByText, press, render, type } from "ariakit-test-utils";
import {
click,
getByRole,
getByText,
press,
render,
type,
} from "ariakit-test-utils";
import { axe } from "jest-axe";
import Example from ".";

Expand All @@ -16,7 +23,7 @@ test("a11y", async () => {
expect(await axe(container)).toHaveNoViolations();
});

test("inline autocomplete", async () => {
test("selection", async () => {
render(<Example />);
await press.Tab();
await type("a");
Expand All @@ -31,5 +38,16 @@ test("inline autocomplete", async () => {
await type("e");
expect(getCombobox()).toHaveValue("ae");
expect(getSelectionValue(getCombobox())).toBe("");
expect(getByText("No results found")).toBeInTheDocument();
});

test("blur input after autocomplete", async () => {
render(<Example />);
await press.Tab();
await type("a");
expect(getCombobox()).toHaveValue("apple");
await press.ArrowDown();
expect(getCombobox()).toHaveValue("Avocado");
await click(document.body);
await click(document.body);
expect(getCombobox()).toHaveValue("Avocado");
});

0 comments on commit cef7aab

Please sign in to comment.