import { describe, expect, it } from "vitest"; import { formatRelativeTimestamp, formatUnknownText, stripThinkingTags } from "./format.ts";
describe("formatAgo", () => {
it("returns 'in <1m' for timestamps less than 60s in the future", () => {
expect(formatRelativeTimestamp(Date.now() + 30_000)).toBe("in <1m");
});
it("returns 'Xm from now' for future timestamps", () => {
expect(formatRelativeTimestamp(Date.now() + 5 * 60_000)).toBe("in 5m");
});
it("returns 'Xh from now' for future timestamps", () => {
expect(formatRelativeTimestamp(Date.now() + 3 * 60 * 60_000)).toBe("in 3h");
});
it("keeps text when tags are unpaired", () => {
expect(stripThinkingTags("<think>\nsecret\nHello")).toBe("secret\nHello");
expect(stripThinkingTags("Hello\n</think>")).toBe("Hello\n");
});
it("returns original text when no tags exist", () => {
expect(stripThinkingTags("Hello")).toBe("Hello");
});
it("handles incomplete <final tag gracefully", () => { // When streaming splits mid-tag, we may see "<final" without closing ">" // This should not crash and should handle gracefully
expect(stripThinkingTags("<final\nHello")).toBe("<final\nHello");
expect(stripThinkingTags("Hello</final>")).toBe("Hello");
});
it("strips <relevant-memories> blocks", () => { const input = [ "<relevant-memories>", "The following memories may be relevant to this conversation:", "- Internal memory note", "</relevant-memories>", "", "User-visible answer",
].join("\n");
expect(stripThinkingTags(input)).toBe("User-visible answer");
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.