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" }, ]); }); });