A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
test: add test for trash cleanup
thecodrrebd302bd60e6
diff --git a/packages/core/__tests__/trash.test.js b/packages/core/__tests__/trash.test.jsindex 084ec3b9c..e955f9915 100644--- a/packages/core/__tests__/trash.test.js+++ b/packages/core/__tests__/trash.test.js@@ -1,3 +1,4 @@+import dayjs from "dayjs";import {StorageInterface,noteTest,@@ -127,3 +128,29 @@ test("restore a notebook that has deleted notes", () =>expect(notebook).toBeDefined();expect(notebook.topics.topic("hello").has(noteId)).toBe(false);}));++test("permanently delete items older than 7 days", () =>+ databaseTest().then(async (db) => {+ const sevenDaysEarlier = dayjs().subtract(8, "days").toDate().getTime();+ const noteId = await db.notes.add(TEST_NOTE);+ const notebookId = await db.notebooks.add(TEST_NOTEBOOK);++ await db.notebooks.delete(notebookId);+ await db.notes.delete(noteId);++ await db.notes._collection.updateItem({+ id: noteId,+ dateDeleted: sevenDaysEarlier,+ });++ await db.notebooks._collection.updateItem({+ id: notebookId,+ dateDeleted: sevenDaysEarlier,+ });++ expect(db.trash.all.length).toBe(2);++ await db.trash.cleanup();++ expect(db.trash.all.length).toBe(0);+ }));