import { describe, expect, it } from "vitest";
import { buildSnippet } from "./snippet";

describe("buildSnippet", () => {
  it("命中关键字时高亮 OCR 片段", () => {
    const snippet = buildSnippet("图像 OCR 测试文本，用于高亮", "OCR");
    expect(snippet).toContain("<mark>OCR</mark>");
  });

  it("无关键字时返回截断文本", () => {
    const snippet = buildSnippet("一段很长的文字用于测试截断逻辑", null);
    expect(snippet.endsWith("…") || snippet.length <= 120).toBe(true);
  });
});
