test: merge logger subsystem prefix drop cases

This commit is contained in:
Peter Steinberger
2026-02-19 08:49:31 +00:00
parent 34ddf0edc0
commit 28377b1506

View File

@@ -122,24 +122,23 @@ describe("globals", () => {
});
describe("stripRedundantSubsystemPrefixForConsole", () => {
it("drops '<subsystem>:' 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 '<Subsystem>:' prefix case-insensitively", () => {
expect(stripRedundantSubsystemPrefixForConsole("WhatsApp: hello", "whatsapp")).toBe("hello");
});
it("drops '<subsystem> ' 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", () => {