mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-10-19 05:50:10 +00:00
Lands the stacked web PRs #75, #79, #80, #81, #83, #85, #87, #89, #92, #95 and #99 in one squash. Server counterparts #166-#176 are merged. Remaining review items follow in a fix PR.
21 lines
1.0 KiB
TypeScript
21 lines
1.0 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
import { SearchBar } from "../../src/components/SearchBar";
|
|
|
|
describe("compact observer search", () => {
|
|
it("omits the field menu and coalesces typing before querying", () => {
|
|
vi.useFakeTimers();
|
|
try {
|
|
const change = vi.fn();
|
|
render(<SearchBar value="" onChange={change} fields={[{ value: "name", label: "Name" }]} field="name" onFieldChange={() => {}} hideField inputLabel="Search observers" />);
|
|
const input = screen.getByRole("textbox", { name: "Search observers" });
|
|
fireEvent.change(input, { target: { value: "Ro" } });
|
|
fireEvent.change(input, { target: { value: "Roof" } });
|
|
expect(change).not.toHaveBeenCalled();
|
|
act(() => vi.advanceTimersByTime(300));
|
|
expect(change).toHaveBeenCalledExactlyOnceWith("Roof");
|
|
expect(screen.queryByRole("button", { name: /Name/ })).not.toBeInTheDocument();
|
|
} finally { vi.useRealTimers(); }
|
|
});
|
|
});
|