You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.7 KiB
57 lines
1.7 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
findGoldStandardTargets,
|
|
loadAllGoldStandardTargets,
|
|
scoreGoldTextMatch,
|
|
} from "@/workers/rpa/gold-standard-targets";
|
|
|
|
describe("gold-standard-targets", () => {
|
|
it("loadAllGoldStandardTargets 读取录证金样本", () => {
|
|
const targets = loadAllGoldStandardTargets();
|
|
expect(targets.length).toBeGreaterThan(0);
|
|
expect(targets[0]?.textPreview.length).toBeGreaterThan(12);
|
|
});
|
|
|
|
it("scoreGoldTextMatch 对完全匹配给高分", () => {
|
|
const text =
|
|
"La Concha Key West, Autograph Collection, Duval Street, Key West, Florida, USA";
|
|
const score = scoreGoldTextMatch(text, {
|
|
street: "Duval Street",
|
|
city: "Key West",
|
|
state: "FL",
|
|
zip: "",
|
|
}, text);
|
|
expect(score).toBeGreaterThanOrEqual(85);
|
|
});
|
|
|
|
it("scoreGoldTextMatch 拒绝仅城市相同的不同街道", () => {
|
|
const score = scoreGoldTextMatch(
|
|
"1234 Warehouse Street, Los Angeles, CA, USA",
|
|
{
|
|
street: "1234 Warehouse Street",
|
|
city: "Los Angeles",
|
|
state: "CA",
|
|
zip: "",
|
|
},
|
|
"Hollywood BoulevardLos Angeles, California, USA",
|
|
);
|
|
expect(score).toBe(0);
|
|
});
|
|
|
|
it("findGoldStandardTargets 按 description 匹配 Key West 金样本", () => {
|
|
const matches = findGoldStandardTargets(
|
|
"La Concha Key West, Autograph Collection, Duval Street, Key West, Florida, USA",
|
|
{
|
|
street: "Duval Street",
|
|
city: "Key West",
|
|
state: "FL",
|
|
zip: "",
|
|
},
|
|
"pickup",
|
|
40,
|
|
);
|
|
expect(matches.length).toBeGreaterThan(0);
|
|
expect(matches[0]?.textPreview).toMatch(/Key West|Duval/i);
|
|
});
|
|
});
|