Files
clawdbot/src/telegram/draft-chunking.test.ts
Peter Steinberger c379191f80 chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
2026-01-14 15:02:19 +00:00

54 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { ClawdbotConfig } from "../../config/config.js";
import { resolveTelegramDraftStreamingChunking } from "./draft-chunking.js";
describe("resolveTelegramDraftStreamingChunking", () => {
it("uses smaller defaults than block streaming", () => {
const chunking = resolveTelegramDraftStreamingChunking(undefined, "default");
expect(chunking).toEqual({
minChars: 200,
maxChars: 800,
breakPreference: "paragraph",
});
});
it("clamps to telegram.textChunkLimit", () => {
const cfg: ClawdbotConfig = {
channels: { telegram: { allowFrom: ["*"], textChunkLimit: 150 } },
};
const chunking = resolveTelegramDraftStreamingChunking(cfg, "default");
expect(chunking).toEqual({
minChars: 150,
maxChars: 150,
breakPreference: "paragraph",
});
});
it("supports per-account overrides", () => {
const cfg: ClawdbotConfig = {
channels: {
telegram: {
allowFrom: ["*"],
accounts: {
default: {
allowFrom: ["*"],
draftChunk: {
minChars: 10,
maxChars: 20,
breakPreference: "sentence",
},
},
},
},
},
};
const chunking = resolveTelegramDraftStreamingChunking(cfg, "default");
expect(chunking).toEqual({
minChars: 10,
maxChars: 20,
breakPreference: "sentence",
});
});
});