Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]
import { describe, expect, it } from "vitest";
import {
buildDeliveryFromLegacyPayload,
buildDeliveryPatchFromLegacyPayload,
hasLegacyDeliveryHints,
mergeLegacyDeliveryInto,
normalizeLegacyDeliveryInput,
} from "./doctor-cron-legacy-delivery.js";
describe("legacy delivery threadId support", () => {
it("treats threadId as a legacy delivery hint", () => {
expect(hasLegacyDeliveryHints({ threadId: "42" })).toBe(true);
expect(hasLegacyDeliveryHints({ threadId: 42 })).toBe(true);
});
it("hydrates threadId into new delivery payloads", () => {
expect(
buildDeliveryFromLegacyPayload({
channel: "telegram",
to: "-100123:topic:42",
threadId: 42,
}),
).toEqual({
mode: "announce",
channel: "telegram",
to: "-100123:topic:42",
threadId: "42",
});
});
it("patches and merges threadId into existing deliveries", () => {
expect(buildDeliveryPatchFromLegacyPayload({ threadId: "77" })).toEqual({
mode: "announce",
threadId: "77",
});
expect(
mergeLegacyDeliveryInto(
{ mode: "announce", channel: "telegram", to: "-100123", threadId: "1" },
{ threadId: 77 },
),
).toEqual({
delivery: { mode: "announce", channel: "telegram", to: "-100123", threadId: "77" },
mutated: true,
});
});
it("strips threadId from legacy payloads after normalization", () => {
const payload: Record<string, unknown> = {
channel: "telegram",
to: "-100123:topic:42",
threadId: 42,
};
expect(normalizeLegacyDeliveryInput({ payload })).toEqual({
delivery: {
mode: "announce",
channel: "telegram",
to: "-100123:topic:42",
threadId: "42",
},
mutated: true,
});
expect(payload.threadId).toBeUndefined();
});
});
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-04-27)
¤
*© Formatika GbR, Deutschland