mirror of
https://github.com/mara-li/obsidian-my-thesaurus.git
synced 2026-07-22 05:38:22 +00:00
test: add another cases in the content
This commit is contained in:
parent
4479f90456
commit
4cc6d903a8
1 changed files with 44 additions and 24 deletions
|
|
@ -2,18 +2,7 @@ import { describe, expect, it } from "bun:test";
|
|||
import type { Thesaurus } from "../src/interfaces";
|
||||
import { getTags } from "../src/utils";
|
||||
|
||||
describe("getTags", () => {
|
||||
it("should return an empty array if no tags are found", () => {
|
||||
const content = "This is a test content without any tags.";
|
||||
const thesaurus: Thesaurus = {
|
||||
tag1: new Set(["synonym1", "synonym2"]),
|
||||
tag2: new Set(["synonym3", "synonym4"]),
|
||||
};
|
||||
|
||||
const result = getTags(content, thesaurus);
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
describe("should return tags", () => {
|
||||
it("should return tags if synonyms are found in the content", () => {
|
||||
const content = "This content contains synonym1 and synonym4.";
|
||||
const thesaurus: Thesaurus = {
|
||||
|
|
@ -35,18 +24,6 @@ describe("getTags", () => {
|
|||
const result = getTags(content, thesaurus);
|
||||
expect(result).toEqual(["tag1", "tag2"]);
|
||||
});
|
||||
|
||||
it("should not return duplicate tags", () => {
|
||||
const content = "This content contains synonym1 and synonym1 again.";
|
||||
const thesaurus: Thesaurus = {
|
||||
tag1: new Set(["synonym1", "synonym2"]),
|
||||
tag2: new Set(["synonym3", "synonym4"]),
|
||||
};
|
||||
|
||||
const result = getTags(content, thesaurus);
|
||||
expect(result).toEqual(["tag1"]);
|
||||
});
|
||||
|
||||
it("should return the two tags related to the synonyms", () => {
|
||||
const content = "This content contains synonym4.";
|
||||
const thesaurus: Thesaurus = {
|
||||
|
|
@ -57,4 +34,47 @@ describe("getTags", () => {
|
|||
const result = getTags(content, thesaurus);
|
||||
expect(result).toEqual(["tag1", "tag2"]);
|
||||
});
|
||||
|
||||
it("should return the tags if the synonyms is equal to the tag", () => {
|
||||
const content = "This content contains tag1.";
|
||||
const thesaurus: Thesaurus = {
|
||||
tag1: new Set(["tag1", "synonym1"]),
|
||||
tag2: new Set(["synonym3", "synonym4"]),
|
||||
};
|
||||
|
||||
const result = getTags(content, thesaurus);
|
||||
expect(result).toEqual(["tag1"]);
|
||||
});
|
||||
});
|
||||
describe("should not return tags", () => {
|
||||
it("should not return duplicate tags", () => {
|
||||
const content = "This content contains synonym1 and synonym1 again.";
|
||||
const thesaurus: Thesaurus = {
|
||||
tag1: new Set(["synonym1", "synonym2"]),
|
||||
tag2: new Set(["synonym3", "synonym4"]),
|
||||
};
|
||||
|
||||
const result = getTags(content, thesaurus);
|
||||
expect(result).toEqual(["tag1"]);
|
||||
});
|
||||
it("should return an empty array if no tags are found", () => {
|
||||
const content = "This is a test content without any tags.";
|
||||
const thesaurus: Thesaurus = {
|
||||
tag1: new Set(["synonym1", "synonym2"]),
|
||||
tag2: new Set(["synonym3", "synonym4"]),
|
||||
};
|
||||
|
||||
const result = getTags(content, thesaurus);
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
it("should not return tags if the synonyms is in a word", () => {
|
||||
const content = "This content contains synonym1word.";
|
||||
const thesaurus: Thesaurus = {
|
||||
tag1: new Set(["synonym1", "synonym2"]),
|
||||
tag2: new Set(["synonym3", "synonym4"]),
|
||||
};
|
||||
|
||||
const result = getTags(content, thesaurus);
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue