Files
buzz-sheet/lib/guides/highlights.test.ts
T
gunshiz ced9b41737
CI / Verify (push) Successful in 1m25s
CI / Build immutable images and deploy (push) Failing after 50s
feat(guide) : improve extra cards and navigation
2026-09-04 22:40:27 +07:00

27 lines
888 B
TypeScript

import { describe, expect, it } from "vitest";
import { highlightTextSegments } from "@/lib/guides/highlights";
describe("Extra text highlights", () => {
it("colors every exact occurrence while preserving surrounding text", () => {
expect(highlightTextSegments("MASSIVE damage\nMASSIVE range", [
{ text: "MASSIVE", color: "#FF0000" },
])).toEqual([
{ text: "MASSIVE", color: "#FF0000" },
{ text: " damage\n", color: null },
{ text: "MASSIVE", color: "#FF0000" },
{ text: " range", color: null },
]);
});
it("prefers the longer phrase when highlights overlap", () => {
expect(highlightTextSegments("very high damage", [
{ text: "high", color: "#00FF00" },
{ text: "high damage", color: "#FF0000" },
])).toEqual([
{ text: "very ", color: null },
{ text: "high damage", color: "#FF0000" },
]);
});
});