mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:31:37 +00:00
perf(test): consolidate reply utility suites
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { matchesMentionWithExplicit } from "./mentions.js";
|
||||
|
||||
describe("matchesMentionWithExplicit", () => {
|
||||
const mentionRegexes = [/\bopenclaw\b/i];
|
||||
|
||||
it("checks mentionPatterns even when explicit mention is available", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "@openclaw hello",
|
||||
mentionRegexes,
|
||||
explicit: {
|
||||
hasAnyMention: true,
|
||||
isExplicitlyMentioned: false,
|
||||
canResolveExplicit: true,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when explicit is false and no regex match", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "<@999999> hello",
|
||||
mentionRegexes,
|
||||
explicit: {
|
||||
hasAnyMention: true,
|
||||
isExplicitlyMentioned: false,
|
||||
canResolveExplicit: true,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true when explicitly mentioned even if regexes do not match", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "<@123456>",
|
||||
mentionRegexes: [],
|
||||
explicit: {
|
||||
hasAnyMention: true,
|
||||
isExplicitlyMentioned: true,
|
||||
canResolveExplicit: true,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("falls back to regex matching when explicit mention cannot be resolved", () => {
|
||||
const result = matchesMentionWithExplicit({
|
||||
text: "openclaw please",
|
||||
mentionRegexes,
|
||||
explicit: {
|
||||
hasAnyMention: true,
|
||||
isExplicitlyMentioned: false,
|
||||
canResolveExplicit: false,
|
||||
},
|
||||
});
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user