aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/lib/__tests__
diff options
context:
space:
mode:
Diffstat (limited to 'packages/trpc/lib/__tests__')
-rw-r--r--packages/trpc/lib/__tests__/search.test.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/trpc/lib/__tests__/search.test.ts b/packages/trpc/lib/__tests__/search.test.ts
index 7f573b4f..9f8aac88 100644
--- a/packages/trpc/lib/__tests__/search.test.ts
+++ b/packages/trpc/lib/__tests__/search.test.ts
@@ -9,6 +9,8 @@ import {
bookmarksInLists,
bookmarkTags,
bookmarkTexts,
+ rssFeedImportsTable,
+ rssFeedsTable,
tagsOnBookmarks,
users,
} from "@hoarder/db/schema";
@@ -151,6 +153,32 @@ beforeEach(async () => {
{ bookmarkId: "b6", listId: "l1" },
]);
+ await db.insert(rssFeedsTable).values([
+ { id: "f1", userId: testUserId, name: "feed1", url: "url1" },
+ { id: "f2", userId: testUserId, name: "feed2", url: "url2" },
+ ]);
+
+ await db.insert(rssFeedImportsTable).values([
+ {
+ id: "imp1",
+ entryId: "entry1",
+ rssFeedId: "f1",
+ bookmarkId: "b1",
+ },
+ {
+ id: "imp2",
+ entryId: "entry2",
+ rssFeedId: "f2",
+ bookmarkId: "b3",
+ },
+ {
+ id: "imp3",
+ entryId: "entry3",
+ rssFeedId: "f1",
+ bookmarkId: "b5",
+ },
+ ]);
+
mockCtx = {
db,
user: {
@@ -423,6 +451,26 @@ describe("getBookmarkIdsFromMatcher", () => {
expect(result).toEqual(["b3"]);
});
+ it("should handle rssFeedName matcher", async () => {
+ const matcher: Matcher = {
+ type: "rssFeedName",
+ feedName: "feed1",
+ inverse: false,
+ };
+ const result = await getBookmarkIdsFromMatcher(mockCtx, matcher);
+ expect(result.sort()).toEqual(["b1", "b5"]);
+ });
+
+ it("should handle rssFeedName matcher with inverse=true", async () => {
+ const matcher: Matcher = {
+ type: "rssFeedName",
+ feedName: "feed1",
+ inverse: true,
+ };
+ const result = await getBookmarkIdsFromMatcher(mockCtx, matcher);
+ expect(result.sort()).toEqual(["b2", "b3", "b4", "b6"]);
+ });
+
it("should throw error for unknown matcher type", async () => {
const matcher = { type: "unknown" } as unknown as Matcher;
await expect(getBookmarkIdsFromMatcher(mockCtx, matcher)).rejects.toThrow(