mirror of
https://github.com/kdnk/obsidian-automatic-linker.git
synced 2026-07-22 05:37:46 +00:00
test: add test cases for non-namespaced and namespaced link replacement
- Add test for non-aliased namespaced path link replacement - Add test for non-namespaced path link replacement without alias - Expand test coverage for link replacement scenarios
This commit is contained in:
parent
af511449d2
commit
9ce0fbdb57
1 changed files with 39 additions and 0 deletions
|
|
@ -144,6 +144,45 @@ describe("replaceLinks - alias handling", () => {
|
|||
});
|
||||
expect(result).toBe("HW");
|
||||
});
|
||||
|
||||
it("should handle non-aliased namespaced path", async () => {
|
||||
const { candidateMap, trie } = buildCandidateTrieForTest({
|
||||
files: [{ path: "pages/set/HelloWorld" }],
|
||||
restrictNamespace: false,
|
||||
baseDir: "pages",
|
||||
});
|
||||
const result = await replaceLinks({
|
||||
body: "HelloWorld",
|
||||
linkResolverContext: {
|
||||
filePath: "pages/set/current",
|
||||
trie,
|
||||
candidateMap,
|
||||
},
|
||||
settings: {
|
||||
minCharCount: 0,
|
||||
namespaceResolution: true,
|
||||
baseDir: "pages",
|
||||
},
|
||||
});
|
||||
expect(result).toBe("[[set/HelloWorld|HelloWorld]]");
|
||||
});
|
||||
|
||||
it("should handle non-namespaced path without alias", async () => {
|
||||
const { candidateMap, trie } = buildCandidateTrieForTest({
|
||||
files: [{ path: "HelloWorld" }],
|
||||
restrictNamespace: false,
|
||||
baseDir: undefined,
|
||||
});
|
||||
const result = await replaceLinks({
|
||||
body: "HelloWorld",
|
||||
linkResolverContext: {
|
||||
filePath: "current",
|
||||
trie,
|
||||
candidateMap,
|
||||
},
|
||||
});
|
||||
expect(result).toBe("[[HelloWorld]]");
|
||||
});
|
||||
});
|
||||
|
||||
describe("alias and baseDir", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue