feat: publish Regex Tools 0.1.0
This commit is contained in:
26
src/components/QuickReference.test.tsx
Normal file
26
src/components/QuickReference.test.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { QuickReference } from "./QuickReference";
|
||||
|
||||
describe("QuickReference", () => {
|
||||
it("shows flavour, flags, example and authoritative source before insertion", async () => {
|
||||
const onInsert = vi.fn();
|
||||
const user = userEvent.setup();
|
||||
render(<QuickReference onInsert={onInsert} />);
|
||||
|
||||
await user.type(
|
||||
screen.getByLabelText("Filter constructs"),
|
||||
"Any character",
|
||||
);
|
||||
expect(screen.getByText("ecmascript")).toBeInTheDocument();
|
||||
expect(screen.getByText("s", { selector: "dd" })).toBeInTheDocument();
|
||||
expect(screen.getByText("a.b")).toBeInTheDocument();
|
||||
expect(
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user