From b62fded4c2cd0ed5f1a9bcd802667ac0811806e5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 11 May 2026 03:07:44 +0100 Subject: [PATCH] test: tighten msteams bot framework assertions --- .../src/attachments/bot-framework.test.ts | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/extensions/msteams/src/attachments/bot-framework.test.ts b/extensions/msteams/src/attachments/bot-framework.test.ts index 9d9e5b5ac50..bbd29ef09cf 100644 --- a/extensions/msteams/src/attachments/bot-framework.test.ts +++ b/extensions/msteams/src/attachments/bot-framework.test.ts @@ -142,7 +142,8 @@ describe("downloadMSTeamsBotFrameworkAttachment", () => { fetchFn, }); - expect(media).toMatchObject({ path: runtime.savePath }); + expect(media?.path).toBe(runtime.savePath); + expect(media?.contentType).toBe(runtime.savedContentType); expect(runtime.saveCalls).toHaveLength(1); expect(runtime.saveCalls[0].buffer.toString("utf-8")).toBe("PDFBYTES"); }); @@ -267,7 +268,8 @@ describe("downloadMSTeamsBotFrameworkAttachment", () => { fetchFn, }); - expect(media).toMatchObject({ path: runtime.savePath }); + expect(media?.path).toBe(runtime.savePath); + expect(media?.contentType).toBe(runtime.savedContentType); // Both the attachment info call and the view call should be observed, // confirming the direct fetch path was taken (no dispatcher interception). expect(fetchCalls).toHaveLength(2); @@ -298,12 +300,11 @@ describe("downloadMSTeamsBotFrameworkAttachment", () => { }); expect(media).toBeUndefined(); - expect(warn).toHaveBeenCalledWith( + expect(warn).toHaveBeenCalledTimes(1); + expect(warn.mock.calls[0]).toStrictEqual([ "msteams botFramework attachmentInfo fetch failed", - expect.objectContaining({ - error: expect.stringContaining("invalid onRequestStart method"), - }), - ); + { error: "fetch failed | invalid onRequestStart method" }, + ]); }); it("logs a warning when the attachmentView fetch throws", async () => { @@ -335,12 +336,11 @@ describe("downloadMSTeamsBotFrameworkAttachment", () => { }); expect(media).toBeUndefined(); - expect(warn).toHaveBeenCalledWith( + expect(warn).toHaveBeenCalledTimes(1); + expect(warn.mock.calls[0]).toStrictEqual([ "msteams botFramework attachmentView fetch failed", - expect.objectContaining({ - error: expect.stringContaining("fetch failed"), - }), - ); + { error: "fetch failed" }, + ]); }); it("logs a warning on non-ok attachmentInfo response", async () => { @@ -362,10 +362,11 @@ describe("downloadMSTeamsBotFrameworkAttachment", () => { }); expect(media).toBeUndefined(); - expect(warn).toHaveBeenCalledWith( + expect(warn).toHaveBeenCalledTimes(1); + expect(warn.mock.calls[0]).toStrictEqual([ "msteams botFramework attachmentInfo non-ok", - expect.objectContaining({ status: 500 }), - ); + { status: 500 }, + ]); }); }); });