dotwee_obsidian-raindropio-.../tests/raindrop-search.test.ts
Lukas Wolfsteiner c22dc1f969 build: modernize TypeScript and esbuild configuration
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>
2026-07-06 11:20:56 +02:00

46 lines
1.5 KiB
TypeScript

import { buildRaindropSearchQuery, buildRaindropTagSearch, formatRaindropTagFilter } from "../src/raindrop-search";
describe("formatRaindropTagFilter", () => {
it("formats simple tags without quotes", () => {
expect(formatRaindropTagFilter("#project/docs")).toBe("#project/docs");
expect(formatRaindropTagFilter("read_later")).toBe("#read_later");
});
it("quotes tags containing spaces or special characters", () => {
expect(formatRaindropTagFilter("read later")).toBe('#"read later"');
expect(formatRaindropTagFilter('work "important"')).toBe('#"work \\"important\\""');
});
it("returns null for empty tags", () => {
expect(formatRaindropTagFilter(" # ")).toBeNull();
});
});
describe("buildRaindropTagSearch", () => {
it("joins tags with implicit AND by default", () => {
expect(buildRaindropTagSearch(["docs", "obsidian"], false)).toBe("#docs #obsidian");
});
it("adds match:OR when matching any tag", () => {
expect(buildRaindropTagSearch(["docs", "obsidian"], true)).toBe("#docs #obsidian match:OR");
});
it("returns undefined when no valid tags are provided", () => {
expect(buildRaindropTagSearch(["", " "], true)).toBeUndefined();
});
});
describe("buildRaindropSearchQuery", () => {
it("combines tag filters and free-text search", () => {
expect(
buildRaindropSearchQuery({
tags: ["docs", "read later"],
search: "obsidian plugin",
}),
).toBe('#docs #"read later" obsidian plugin');
});
it("trims empty query parts", () => {
expect(buildRaindropSearchQuery({ search: " ", tags: [] })).toBeUndefined();
});
});