mirror of
https://github.com/mara-li/obsidian-my-thesaurus.git
synced 2026-07-22 05:38:22 +00:00
test: add tests for accent handling in thesaurus and tag retrieval
This commit is contained in:
parent
9af25f93eb
commit
dc2e2853e0
2 changed files with 43 additions and 0 deletions
|
|
@ -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);
|
||||
})
|
||||
})
|
||||
|
|
@ -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"]);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue