From 0c1d3b866c11b42ce66e2e1176c92cecf7027cd8 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 19 Feb 2026 09:48:47 +0000 Subject: [PATCH] test(bluebubbles): collapse duplicate credential and chatGuid cases --- extensions/bluebubbles/src/chat.test.ts | 50 ++++++++----------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/extensions/bluebubbles/src/chat.test.ts b/extensions/bluebubbles/src/chat.test.ts index b5dd0973449..f39dfbf540a 100644 --- a/extensions/bluebubbles/src/chat.test.ts +++ b/extensions/bluebubbles/src/chat.test.ts @@ -13,29 +13,20 @@ installBlueBubblesFetchTestHooks({ describe("chat", () => { describe("markBlueBubblesChatRead", () => { - it("does nothing when chatGuid is empty", async () => { - await markBlueBubblesChatRead("", { - serverUrl: "http://localhost:1234", - password: "test", - }); + it("does nothing when chatGuid is empty or whitespace", async () => { + for (const chatGuid of ["", " "]) { + await markBlueBubblesChatRead(chatGuid, { + serverUrl: "http://localhost:1234", + password: "test", + }); + } expect(mockFetch).not.toHaveBeenCalled(); }); - it("does nothing when chatGuid is whitespace", async () => { - await markBlueBubblesChatRead(" ", { - serverUrl: "http://localhost:1234", - password: "test", - }); - expect(mockFetch).not.toHaveBeenCalled(); - }); - - it("throws when serverUrl is missing", async () => { + it("throws when required credentials are missing", async () => { await expect(markBlueBubblesChatRead("chat-guid", {})).rejects.toThrow( "serverUrl is required", ); - }); - - it("throws when password is missing", async () => { await expect( markBlueBubblesChatRead("chat-guid", { serverUrl: "http://localhost:1234", @@ -141,29 +132,20 @@ describe("chat", () => { }); describe("sendBlueBubblesTyping", () => { - it("does nothing when chatGuid is empty", async () => { - await sendBlueBubblesTyping("", true, { - serverUrl: "http://localhost:1234", - password: "test", - }); + it("does nothing when chatGuid is empty or whitespace", async () => { + for (const chatGuid of ["", " "]) { + await sendBlueBubblesTyping(chatGuid, true, { + serverUrl: "http://localhost:1234", + password: "test", + }); + } expect(mockFetch).not.toHaveBeenCalled(); }); - it("does nothing when chatGuid is whitespace", async () => { - await sendBlueBubblesTyping(" ", false, { - serverUrl: "http://localhost:1234", - password: "test", - }); - expect(mockFetch).not.toHaveBeenCalled(); - }); - - it("throws when serverUrl is missing", async () => { + it("throws when required credentials are missing", async () => { await expect(sendBlueBubblesTyping("chat-guid", true, {})).rejects.toThrow( "serverUrl is required", ); - }); - - it("throws when password is missing", async () => { await expect( sendBlueBubblesTyping("chat-guid", true, { serverUrl: "http://localhost:1234",