Files
openclaw/src/plugin-sdk/format-capabilities.test.ts
Peter Steinberger aae10cade5 refactor(markdown): unify format profile declarations (#113254)
* refactor(markdown): unify format profile declarations

* test(markdown): avoid suppression inventory drift
2026-07-24 00:37:59 -07:00

47 lines
1.6 KiB
TypeScript

import { describe, expect, expectTypeOf, it } from "vitest";
import { FormatCapabilityProfile } from "./text-chunking.js";
describe("FormatCapabilityProfile", () => {
it("defaults constructs to native while preserving override literals", () => {
const profile = FormatCapabilityProfile.define({
mechanism: "ranges",
constructs: {
underline: "strip",
spoiler: "fallback",
codeLanguage: "strip",
linkLabel: "fallback",
heading: "fallback",
bulletList: "fallback",
orderedList: "fallback",
taskList: "fallback",
table: "strip",
blockquote: "fallback",
image: "strip",
},
chunk: { limit: 2_048, unit: "bytes", hardCap: 65_536 },
});
expectTypeOf(profile.mechanism).toEqualTypeOf<"ranges">();
expectTypeOf(profile.constructs.bold).toEqualTypeOf<"native">();
expectTypeOf(profile.constructs.underline).toEqualTypeOf<"strip">();
expectTypeOf(profile.chunk.unit).toEqualTypeOf<"bytes">();
expect(profile.constructs.bold).toBe("native");
expect(profile.chunk.hardCap).toBe(65_536);
});
it("rejects unknown construct overrides", () => {
type MisspelledProfile = {
mechanism: "markdown";
constructs: { table: "fallback"; blockqoute: "fallback" };
chunk: { limit: number; unit: "chars" };
};
type AcceptsMisspelledProfile = typeof FormatCapabilityProfile.define extends (
profile: MisspelledProfile,
) => unknown
? true
: false;
expectTypeOf<AcceptsMisspelledProfile>().toEqualTypeOf<false>();
});
});