mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 17:02:17 +00:00
Add rectangular database cell selection and TSV copy/paste, plus schema-aware SQL completion and highlighting in WHERE and ORDER BY fields. Preserve whitespace in highlighted SQL and match the input caret scroll width so the overlay remains aligned. Co-authored-by: zzxzz12345 <[email protected]>
20 lines
1.1 KiB
TypeScript
20 lines
1.1 KiB
TypeScript
import { render, waitFor } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { SqlHighlight } from "./SqlHighlight";
|
|
|
|
describe("SQL filter highlighting", () => {
|
|
it("uses the console SQL language and theme to highlight keywords, strings and numbers", async () => {
|
|
const { container } = render(<SqlHighlight text="name = 'active' AND id > 12" />);
|
|
await waitFor(() => expect(container.querySelectorAll("span[class]").length).toBeGreaterThanOrEqual(3));
|
|
expect(container.textContent).toContain("name = 'active' AND id > 12");
|
|
});
|
|
it("wraps the gaps between tokens so flex layout keeps single spaces", async () => {
|
|
const { container } = render(<SqlHighlight text="age > 20 AND id = 1" />);
|
|
await waitFor(() => expect(container.querySelectorAll("span[class]").length).toBeGreaterThanOrEqual(3));
|
|
const bare = [...container.childNodes].filter((n) => n.nodeType === Node.TEXT_NODE);
|
|
expect(bare).toEqual([]);
|
|
const spans = [...container.children].filter((n) => n.tagName === "SPAN");
|
|
expect(spans.map((n) => n.textContent).join("")).toBe("age > 20 AND id = 1");
|
|
});
|
|
});
|