test: add tests for accent handling in thesaurus and tag retrieval

This commit is contained in:
Mara-Li 2025-02-21 08:35:10 +01:00
parent 9af25f93eb
commit dc2e2853e0
2 changed files with 43 additions and 0 deletions

View file

@ -117,3 +117,29 @@ describe("markdown table", () => {
).toThrow("Invalid header length: 3");
});
});
describe("With accents", () => {
it("passing markdown table", () => {
const csvContent =
"| Term | Synonyms |\n" +
"| ----- | -------- |\n" +
"| café | café |\n" +
"| rôle | rôle |\n";
const expected = {
café: new Set(["cafe"]),
rôle: new Set(["role"]),
}
const separator: Separator = "md";
const thesaurus = getThesaurus(csvContent, separator, mockTranslation, columnNames, true);
expect(thesaurus).toEqual(expected);
})
it("passing csv", () =>{
const csvContent = "Term,Synonyms\ncafé,café\nrôle,rôle";
const expected = {
café: new Set(["cafe"]),
rôle: new Set(["role"]),
}
const separator: Separator = ",";
const thesaurus = getThesaurus(csvContent, separator, mockTranslation, columnNames, true);
expect(thesaurus).toEqual(expected);
})
})

View file

@ -77,3 +77,20 @@ describe("should not return tags", () => {
expect(result).toEqual([]);
});
});
describe("Find without accents", () => {
const thesaurus: Thesaurus = {
cafe: new Set(["cafe", "chocolate"]),
role: new Set(["role", "roliste"]),
};
it("should find tag with accents", () => {
const content = "This content contains café.";
const result = getTags(content, thesaurus, true);
expect(result).toEqual(["cafe"]);
});
it("should find tag without accents", () => {
const content = "This content contains cafe.";
const result = getTags(content, thesaurus, true);
expect(result).toEqual(["cafe"]);
});
});