diff --git a/src/logger.test.ts b/src/logger.test.ts index ccb1b2361b..d438cf3a71 100644 --- a/src/logger.test.ts +++ b/src/logger.test.ts @@ -122,24 +122,23 @@ describe("globals", () => { }); describe("stripRedundantSubsystemPrefixForConsole", () => { - it("drops ':' prefix", () => { - expect(stripRedundantSubsystemPrefixForConsole("discord: hello", "discord")).toBe("hello"); - }); + it("drops known subsystem prefixes", () => { + const cases = [ + { input: "discord: hello", subsystem: "discord", expected: "hello" }, + { input: "WhatsApp: hello", subsystem: "whatsapp", expected: "hello" }, + { input: "discord gateway: closed", subsystem: "discord", expected: "gateway: closed" }, + { + input: "[discord] connection stalled", + subsystem: "discord", + expected: "connection stalled", + }, + ]; - it("drops ':' prefix case-insensitively", () => { - expect(stripRedundantSubsystemPrefixForConsole("WhatsApp: hello", "whatsapp")).toBe("hello"); - }); - - it("drops ' ' prefix", () => { - expect(stripRedundantSubsystemPrefixForConsole("discord gateway: closed", "discord")).toBe( - "gateway: closed", - ); - }); - - it("drops '[subsystem]' prefix", () => { - expect(stripRedundantSubsystemPrefixForConsole("[discord] connection stalled", "discord")).toBe( - "connection stalled", - ); + for (const testCase of cases) { + expect(stripRedundantSubsystemPrefixForConsole(testCase.input, testCase.subsystem)).toBe( + testCase.expected, + ); + } }); it("keeps messages that do not start with the subsystem", () => {