feat: publish Regex Tools 0.2.0

This commit is contained in:
2026-07-27 01:06:57 +02:00
parent 873b9b218d
commit 4951c966d4
180 changed files with 35344 additions and 503 deletions

View File

@@ -5,9 +5,9 @@ import { QuickReference } from "./QuickReference";
describe("QuickReference", () => {
it("shows flavour, flags, example and authoritative source before insertion", async () => {
const onInsert = vi.fn();
const onUsePattern = vi.fn();
const user = userEvent.setup();
render(<QuickReference onInsert={onInsert} />);
render(<QuickReference onUsePattern={onUsePattern} />);
await user.type(
screen.getByLabelText("Filter constructs"),
@@ -20,7 +20,37 @@ describe("QuickReference", () => {
screen.getByRole("link", { name: "ECMAScript Atom grammar" }),
).toHaveAttribute("href", expect.stringContaining("tc39.es"));
await user.click(screen.getByRole("button", { name: "Insert example" }));
expect(onInsert).toHaveBeenCalledWith("a.b");
await user.click(
screen.getByRole("button", { name: "Use example as pattern" }),
);
expect(onUsePattern).toHaveBeenCalledWith("a.b");
});
it("shows an explicit empty state for a filter without matches", async () => {
const user = userEvent.setup();
render(<QuickReference onUsePattern={vi.fn()} />);
await user.type(
screen.getByLabelText("Filter constructs"),
"no such construct",
);
expect(screen.getByRole("status")).toHaveTextContent(
"No reference constructs match",
);
expect(screen.getByText("0 of 12 constructs")).toBeInTheDocument();
});
it("switches to the authoritative PCRE2 construct set", async () => {
const user = userEvent.setup();
render(<QuickReference flavour="pcre2" onUsePattern={vi.fn()} />);
expect(screen.getByText("Original PCRE2 reference")).toBeInTheDocument();
expect(screen.getByText("8 of 8 constructs")).toBeInTheDocument();
await user.type(screen.getByLabelText("Filter constructs"), "branch reset");
expect(screen.getByText("Branch-reset group")).toBeInTheDocument();
expect(
screen.getByRole("link", { name: "PCRE2 pattern documentation" }),
).toHaveAttribute("href", expect.stringContaining("pcre.org"));
});
});