48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { resolveTelegramConversationId } from "./telegram-context.js";
|
|
|
|
describe("resolveTelegramConversationId", () => {
|
|
it("builds canonical topic ids from chat target and message thread id", () => {
|
|
const conversationId = resolveTelegramConversationId({
|
|
ctx: {
|
|
OriginatingTo: "-100200300",
|
|
MessageThreadId: "77",
|
|
},
|
|
command: {},
|
|
});
|
|
expect(conversationId).toBe("-100200300:topic:77");
|
|
});
|
|
|
|
it("returns the direct-message chat id when no topic id is present", () => {
|
|
const conversationId = resolveTelegramConversationId({
|
|
ctx: {
|
|
OriginatingTo: "123456",
|
|
},
|
|
command: {},
|
|
});
|
|
expect(conversationId).toBe("123456");
|
|
});
|
|
|
|
it("does not treat non-topic groups as globally bindable conversations", () => {
|
|
const conversationId = resolveTelegramConversationId({
|
|
ctx: {
|
|
OriginatingTo: "-100200300",
|
|
},
|
|
command: {},
|
|
});
|
|
expect(conversationId).toBeUndefined();
|
|
});
|
|
|
|
it("falls back to command target when originating target is missing", () => {
|
|
const conversationId = resolveTelegramConversationId({
|
|
ctx: {
|
|
To: "123456",
|
|
},
|
|
command: {
|
|
to: "78910",
|
|
},
|
|
});
|
|
expect(conversationId).toBe("78910");
|
|
});
|
|
});
|