From cd55f443d9de8e85a7e4b3db0fb32178aa8652b2 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 19 Feb 2024 16:35:39 +0500 Subject: [PATCH] core: add more lookup tests --- packages/core/__tests__/lookup.test.js | 33 +++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/core/__tests__/lookup.test.js b/packages/core/__tests__/lookup.test.js index e5a19e6b7..cfae8afb7 100644 --- a/packages/core/__tests__/lookup.test.js +++ b/packages/core/__tests__/lookup.test.js @@ -17,7 +17,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import { noteTest, TEST_NOTE, notebookTest, TEST_NOTEBOOK2 } from "./utils"; +import { + noteTest, + TEST_NOTE, + notebookTest, + TEST_NOTEBOOK2, + databaseTest +} from "./utils"; import { test, expect } from "vitest"; const content = { @@ -64,3 +70,28 @@ test("search notebooks", () => let filtered = await db.lookup.notebooks("Description").ids(); expect(filtered.length).toBeGreaterThan(0); })); + +test("search should not return trashed notes", () => + databaseTest().then(async (db) => { + const id = await db.notes.add({ + title: "world is a heavy tune" + }); + await db.notes.moveToTrash(id); + + const filtered = await db.lookup.notes("heavy tune").ids(); + + expect(filtered).toHaveLength(0); + })); + +test("search should return restored notes", () => + databaseTest().then(async (db) => { + const id = await db.notes.add({ + title: "world is a heavy tune" + }); + await db.notes.moveToTrash(id); + await db.trash.restore(id); + + const filtered = await db.lookup.notes("heavy tune").ids(); + + expect(filtered).toHaveLength(1); + }));