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
tests: add test for search and fix bug
thecodrr09978594e4e6
diff --git a/packages/core/__tests__/database.test.js b/packages/core/__tests__/database.test.jsindex 4c8260f99..b9761474a 100644--- a/packages/core/__tests__/database.test.js+++ b/packages/core/__tests__/database.test.js@@ -52,3 +52,8 @@ test("get all notes", async () => {let notes = await db.getNotes();expect(notes.length).toBeGreaterThan(0);});++test("search all notes", async () => {+ let filtered = await db.searchNotes("text");+ expect(filtered.length).toBeGreaterThan(0);+});diff --git a/packages/core/api/database.js b/packages/core/api/database.jsindex 087f04be2..86801174e 100644--- a/packages/core/api/database.js+++ b/packages/core/api/database.js@@ -82,10 +82,11 @@ class Database {* Searches all notes in the database with the given query* @param {string} query the search query*/- searchNotes(query) {- //TODO add logic to update the cache if necessary+ async searchNotes(query) {+ let notes = await this.getNotes();+ if (!notes) return;return ff(- this.notes,+ notes,v => fuzzysearch(query, v.title) || fuzzysearch(query, v.content.text),this);