mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
test: merge logger subsystem prefix drop cases
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user