From 3208dda3848ad739f54cebf44c423e2b68e85b2d Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 28 Feb 2024 20:45:28 +0000 Subject: feature: Add support for storing and previewing raw notes --- packages/web/server/api/routers/bookmarks.test.ts | 36 +++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'packages/web/server/api/routers/bookmarks.test.ts') diff --git a/packages/web/server/api/routers/bookmarks.test.ts b/packages/web/server/api/routers/bookmarks.test.ts index 16f82992..603a173e 100644 --- a/packages/web/server/api/routers/bookmarks.test.ts +++ b/packages/web/server/api/routers/bookmarks.test.ts @@ -1,17 +1,18 @@ import { CustomTestContext, defaultBeforeEach } from "@/lib/testUtils"; -import { expect, describe, test, beforeEach } from "vitest"; +import { expect, describe, test, beforeEach, assert } from "vitest"; beforeEach(defaultBeforeEach); describe("Bookmark Routes", () => { test("create bookmark", async ({ apiCallers }) => { const api = apiCallers[0].bookmarks; - const bookmark = await api.bookmarkLink({ + const bookmark = await api.createBookmark({ url: "https://google.com", type: "link", }); const res = await api.getBookmark({ bookmarkId: bookmark.id }); + assert(res.content.type == "link"); expect(res.content.url).toEqual("https://google.com"); expect(res.favourited).toEqual(false); expect(res.archived).toEqual(false); @@ -22,7 +23,7 @@ describe("Bookmark Routes", () => { const api = apiCallers[0].bookmarks; // Create the bookmark - const bookmark = await api.bookmarkLink({ + const bookmark = await api.createBookmark({ url: "https://google.com", type: "link", }); @@ -43,7 +44,7 @@ describe("Bookmark Routes", () => { const api = apiCallers[0].bookmarks; // Create the bookmark - const bookmark = await api.bookmarkLink({ + const bookmark = await api.createBookmark({ url: "https://google.com", type: "link", }); @@ -64,12 +65,12 @@ describe("Bookmark Routes", () => { const emptyBookmarks = await api.getBookmarks({}); expect(emptyBookmarks.bookmarks.length).toEqual(0); - const bookmark1 = await api.bookmarkLink({ + const bookmark1 = await api.createBookmark({ url: "https://google.com", type: "link", }); - const bookmark2 = await api.bookmarkLink({ + const bookmark2 = await api.createBookmark({ url: "https://google2.com", type: "link", }); @@ -113,7 +114,7 @@ describe("Bookmark Routes", () => { test("update tags", async ({ apiCallers }) => { const api = apiCallers[0].bookmarks; - let bookmark = await api.bookmarkLink({ + let bookmark = await api.createBookmark({ url: "https://google.com", type: "link", }); @@ -139,12 +140,29 @@ describe("Bookmark Routes", () => { expect(bookmark.tags.map((t) => t.name).sort()).toEqual(["tag2", "tag3"]); }); + test("update bookmark text", async ({ apiCallers }) => { + const api = apiCallers[0].bookmarks; + let bookmark = await api.createBookmark({ + text: "HELLO WORLD", + type: "text", + }); + + await api.updateBookmarkText({ + bookmarkId: bookmark.id, + text: "WORLD HELLO", + }); + + bookmark = await api.getBookmark({ bookmarkId: bookmark.id }); + assert(bookmark.content.type == "text"); + expect(bookmark.content.text).toEqual("WORLD HELLO"); + }); + test("privacy", async ({ apiCallers }) => { - const user1Bookmark = await apiCallers[0].bookmarks.bookmarkLink({ + const user1Bookmark = await apiCallers[0].bookmarks.createBookmark({ type: "link", url: "https://google.com", }); - const user2Bookmark = await apiCallers[1].bookmarks.bookmarkLink({ + const user2Bookmark = await apiCallers[1].bookmarks.createBookmark({ type: "link", url: "https://google.com", }); -- cgit v1.2.3-70-g09d2