mirror of
https://github.com/dotwee/obsidian-raindropio-plugin.git
synced 2026-07-22 06:50:29 +00:00
Set compile and bundle target to ES2021 since Obsidian runs on modern Electron. Replace individual strict flags with strict: true and add noFallthroughCasesInSwitch, skipLibCheck and forceConsistentCasingInFileNames. Switch module resolution to bundler, removing the need for deprecation workarounds on TypeScript 6. Drop baseUrl, allowJs and importHelpers; tests now import sources via relative paths. Aligns the project with the modernized obsidian-sample-plugin configuration. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import type { CachedMetadata } from "obsidian";
|
|
import { getNoteRaindropReferences, getUrlKey } from "../src/note-parser";
|
|
|
|
describe("getNoteRaindropReferences", () => {
|
|
it("extracts unique tags and urls from a note", () => {
|
|
const metadata: CachedMetadata = {
|
|
tags: [{ tag: "#research", position: { start: { line: 0, col: 0, offset: 0 }, end: { line: 0, col: 9, offset: 9 } } }],
|
|
frontmatter: {
|
|
tags: ["saved", "#research"],
|
|
},
|
|
};
|
|
const source = [
|
|
"[Obsidian](https://obsidian.md/)",
|
|
"https://raindrop.io/library,",
|
|
"https://obsidian.md/",
|
|
].join("\n");
|
|
|
|
expect(getNoteRaindropReferences(source, metadata)).toEqual({
|
|
tags: ["research", "saved"],
|
|
urls: ["https://obsidian.md/", "https://raindrop.io/library"],
|
|
});
|
|
});
|
|
|
|
it("handles notes without metadata", () => {
|
|
expect(getNoteRaindropReferences("No links here", null)).toEqual({
|
|
tags: [],
|
|
urls: [],
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("getUrlKey", () => {
|
|
it("normalizes equivalent urls for comparison", () => {
|
|
expect(getUrlKey("https://Example.com/path/#section")).toBe("https://example.com/path");
|
|
expect(getUrlKey("https://example.com/path/")).toBe("https://example.com/path");
|
|
});
|
|
|
|
it("falls back to lower-cased text for invalid urls", () => {
|
|
expect(getUrlKey("Example/Path/")).toBe("example/path");
|
|
});
|
|
});
|