mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 14:54:31 +00:00
chore(tsgo/format): fix CI errors
This commit is contained in:
@@ -237,11 +237,15 @@ describe("edge cases", () => {
|
||||
] as const;
|
||||
for (const testCase of cases) {
|
||||
const result = markdownToTelegramHtml(testCase.input);
|
||||
for (const expected of testCase.contains ?? []) {
|
||||
expect(result, testCase.name).toContain(expected);
|
||||
if ("contains" in testCase) {
|
||||
for (const expected of testCase.contains) {
|
||||
expect(result, testCase.name).toContain(expected);
|
||||
}
|
||||
}
|
||||
for (const unexpected of testCase.notContains ?? []) {
|
||||
expect(result, testCase.name).not.toContain(unexpected);
|
||||
if ("notContains" in testCase) {
|
||||
for (const unexpected of testCase.notContains) {
|
||||
expect(result, testCase.name).not.toContain(unexpected);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -297,8 +301,10 @@ describe("edge cases", () => {
|
||||
if ("expectedExact" in testCase) {
|
||||
expect(result, testCase.name).toBe(testCase.expectedExact);
|
||||
}
|
||||
for (const expected of testCase.contains ?? []) {
|
||||
expect(result, testCase.name).toContain(expected);
|
||||
if ("contains" in testCase) {
|
||||
for (const expected of testCase.contains) {
|
||||
expect(result, testCase.name).toContain(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -166,7 +166,7 @@ describe("buildModelsKeyboard", () => {
|
||||
for (const testCase of cases) {
|
||||
const result = buildModelsKeyboard({
|
||||
provider: "anthropic",
|
||||
models: testCase.params.models,
|
||||
models: [...testCase.params.models],
|
||||
currentPage: testCase.params.currentPage,
|
||||
totalPages: 3,
|
||||
pageSize: 2,
|
||||
|
||||
@@ -74,7 +74,11 @@ describe("sent-message-cache", () => {
|
||||
|
||||
describe("buildInlineKeyboard", () => {
|
||||
it("normalizes keyboard inputs", () => {
|
||||
const cases = [
|
||||
const cases: Array<{
|
||||
name: string;
|
||||
input: Parameters<typeof buildInlineKeyboard>[0];
|
||||
expected: ReturnType<typeof buildInlineKeyboard>;
|
||||
}> = [
|
||||
{
|
||||
name: "empty input",
|
||||
input: undefined,
|
||||
@@ -141,7 +145,7 @@ describe("buildInlineKeyboard", () => {
|
||||
inline_keyboard: [[{ text: "Ok", callback_data: "cmd:ok" }]],
|
||||
},
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
for (const testCase of cases) {
|
||||
expect(buildInlineKeyboard(testCase.input), testCase.name).toEqual(testCase.expected);
|
||||
}
|
||||
@@ -539,7 +543,12 @@ describe("sendMessageTelegram", () => {
|
||||
|
||||
it("applies reply markup and thread options to split video-note sends", async () => {
|
||||
const chatId = "123";
|
||||
const cases = [
|
||||
const cases: Array<{
|
||||
text: string;
|
||||
options: Partial<NonNullable<Parameters<typeof sendMessageTelegram>[2]>>;
|
||||
expectedVideoNote: Record<string, unknown>;
|
||||
expectedMessage: Record<string, unknown>;
|
||||
}> = [
|
||||
{
|
||||
text: "Check this out",
|
||||
options: {
|
||||
@@ -564,7 +573,7 @@ describe("sendMessageTelegram", () => {
|
||||
reply_to_message_id: 999,
|
||||
},
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
const sendVideoNote = vi.fn().mockResolvedValue({
|
||||
@@ -681,7 +690,19 @@ describe("sendMessageTelegram", () => {
|
||||
});
|
||||
|
||||
it("routes audio media to sendAudio/sendVoice based on voice compatibility", async () => {
|
||||
const cases = [
|
||||
const cases: Array<{
|
||||
name: string;
|
||||
chatId: string;
|
||||
text: string;
|
||||
mediaUrl: string;
|
||||
contentType: string;
|
||||
fileName: string;
|
||||
asVoice?: boolean;
|
||||
messageThreadId?: number;
|
||||
replyToMessageId?: number;
|
||||
expectedMethod: "sendAudio" | "sendVoice";
|
||||
expectedOptions: Record<string, unknown>;
|
||||
}> = [
|
||||
{
|
||||
name: "default audio send",
|
||||
chatId: "123",
|
||||
@@ -732,7 +753,7 @@ describe("sendMessageTelegram", () => {
|
||||
expectedMethod: "sendVoice" as const,
|
||||
expectedOptions: { caption: "caption", parse_mode: "HTML" },
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
const sendAudio = vi.fn().mockResolvedValue({
|
||||
@@ -1210,12 +1231,22 @@ describe("editMessageTelegram", () => {
|
||||
});
|
||||
|
||||
it("handles button payload + parse fallback behavior", async () => {
|
||||
const cases = [
|
||||
const cases: Array<{
|
||||
name: string;
|
||||
setup: () => {
|
||||
text: string;
|
||||
buttons: Parameters<typeof buildInlineKeyboard>[0];
|
||||
};
|
||||
expectedCalls: number;
|
||||
firstExpectNoReplyMarkup?: boolean;
|
||||
firstExpectReplyMarkup?: Record<string, unknown>;
|
||||
secondExpectReplyMarkup?: Record<string, unknown>;
|
||||
}> = [
|
||||
{
|
||||
name: "buttons undefined keeps existing keyboard",
|
||||
setup: () => {
|
||||
botApi.editMessageText.mockResolvedValue({ message_id: 1, chat: { id: "123" } });
|
||||
return { text: "hi", buttons: undefined as [] | undefined };
|
||||
return { text: "hi", buttons: undefined };
|
||||
},
|
||||
expectedCalls: 1,
|
||||
firstExpectNoReplyMarkup: true,
|
||||
@@ -1224,7 +1255,7 @@ describe("editMessageTelegram", () => {
|
||||
name: "buttons empty clears keyboard",
|
||||
setup: () => {
|
||||
botApi.editMessageText.mockResolvedValue({ message_id: 1, chat: { id: "123" } });
|
||||
return { text: "hi", buttons: [] as [] };
|
||||
return { text: "hi", buttons: [] };
|
||||
},
|
||||
expectedCalls: 1,
|
||||
firstExpectReplyMarkup: { inline_keyboard: [] },
|
||||
@@ -1235,13 +1266,13 @@ describe("editMessageTelegram", () => {
|
||||
botApi.editMessageText
|
||||
.mockRejectedValueOnce(new Error("400: Bad Request: can't parse entities"))
|
||||
.mockResolvedValueOnce({ message_id: 1, chat: { id: "123" } });
|
||||
return { text: "<bad> html", buttons: [] as [] };
|
||||
return { text: "<bad> html", buttons: [] };
|
||||
},
|
||||
expectedCalls: 2,
|
||||
firstExpectReplyMarkup: { inline_keyboard: [] },
|
||||
secondExpectReplyMarkup: { inline_keyboard: [] },
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
botApi.editMessageText.mockReset();
|
||||
|
||||
Reference in New Issue
Block a user