38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
||
import {
|
||
mergeKnownOrganizations,
|
||
normalizeOrganizationScopeSearchText,
|
||
resolveOrganizationSelectionFromMessage,
|
||
scoreOrganizationMentionInMessage
|
||
} from "../src/services/assistantOrganizationMatcher";
|
||
|
||
describe("assistant organization matcher", () => {
|
||
it("deduplicates known organizations by normalized search key", () => {
|
||
expect(
|
||
mergeKnownOrganizations([
|
||
'ООО "Альтернатива Плюс"',
|
||
"ооо альтернатива плюс",
|
||
"ООО Лайсвуд"
|
||
])
|
||
).toEqual(['ООО "Альтернатива Плюс"', "ООО Лайсвуд"]);
|
||
});
|
||
|
||
it("matches incomplete or reordered organization mention against live candidates", () => {
|
||
const resolved = resolveOrganizationSelectionFromMessage("дай что сегодня на складе в конторе ссыт кот", [
|
||
"ООО КОТ ССЫТ ВО ДВОРЕ",
|
||
"ООО Альтернатива Плюс"
|
||
]);
|
||
|
||
expect(resolved).toBe("ООО КОТ ССЫТ ВО ДВОРЕ");
|
||
});
|
||
|
||
it("scores direct and fuzzy token overlap above ambiguity threshold", () => {
|
||
const score = scoreOrganizationMentionInMessage(
|
||
normalizeOrganizationScopeSearchText("что на складе конторы альтернатива"),
|
||
'ООО "Альтернатива Плюс"'
|
||
);
|
||
|
||
expect(score).toBeGreaterThanOrEqual(90);
|
||
});
|
||
});
|