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
core: fix tests
Abdullah Atta6f8033429625
diff --git a/packages/core/__mocks__/node-storage.mock.ts b/packages/core/__mocks__/node-storage.mock.tsindex 191118755..a986866f1 100644--- a/packages/core/__mocks__/node-storage.mock.ts+++ b/packages/core/__mocks__/node-storage.mock.ts@@ -17,7 +17,12 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { Cipher, NNCrypto, SerializedKey } from "@notesnook/crypto";+import {+ Cipher,+ NNCrypto,+ SerializedKey,+ SerializedKeyPair+} from "@notesnook/crypto";import { IStorage } from "../src/interfaces.js";export class NodeStorageInterface implements IStorage {@@ -109,4 +114,17 @@ export class NodeStorageInterface implements IStorage {): Promise<SerializedKey> {return { password, salt };}++ generateCryptoKeyPair(): Promise<SerializedKeyPair> {+ throw new Error("Method not implemented.");+ }+ generateCryptoKeyFallback(+ password: string,+ salt?: string+ ): Promise<SerializedKey> {+ throw new Error("Method not implemented.");+ }+ deriveCryptoKeyFallback(credentials: SerializedKey): Promise<void> {+ throw new Error("Method not implemented.");+ }}diff --git a/packages/core/__tests__/utils/index.ts b/packages/core/__tests__/utils/index.tsindex 7ec102f35..8f3a2fe1b 100644--- a/packages/core/__tests__/utils/index.ts+++ b/packages/core/__tests__/utils/index.ts@@ -57,6 +57,7 @@ function databaseTest(type: "memory" | "persistent" = "memory") {eventsource: EventSource,fs: FS,compressor: async () => Compressor,+ maxNoteVersions: async () => 1000,sqliteOptions: {dialect: (name) =>new SqliteDialect({diff --git a/packages/core/src/utils/__tests__/query-transformer.test.ts b/packages/core/src/utils/__tests__/query-transformer.test.tsindex 492170d23..8e1dc76d7 100644--- a/packages/core/src/utils/__tests__/query-transformer.test.ts+++ b/packages/core/src/utils/__tests__/query-transformer.test.ts@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import { expect, test } from "vitest";import { transformQuery } from "../query-transformer.js";-const TRANSFORM_QUERY_TESTS: [string, string][] = [+const TRANSFORM_QUERY_TESTS: [string, string | undefined][] = [["hello world", `hello AND world`],["hello world OR bar", `hello AND world OR bar`],["hello world OR bar NOT baz", `hello AND world OR bar NOT baz`],@@ -29,34 +29,37 @@ const TRANSFORM_QUERY_TESTS: [string, string][] = [["hello world -foo", `hello AND world AND "-foo"`],["hello world phrase-with-dash", `hello AND world AND "phrase-with-dash"`],["hello world phrase-with-dash*", 'hello AND world AND "phrase-with-dash*"'],- ["example + foo + bar", `example AND foo AND bar`],+ ["example + foo + bar", `example AND "+" AND foo AND "+" AND bar`],["example OR foo NOT bar", `example OR foo NOT bar`],['example "quoted phrase" "another quoted phrase"',`example AND "quoted phrase" AND "another quoted phrase"`],['"phrase-with-dash*"', `"phrase-with-dash*"`],- ['-foo + bar OR "quoted-phrase"', `"-foo" AND bar OR "quoted-phrase"`],+ [+ '-foo + bar OR "quoted-phrase"',+ `"-foo" AND "+" AND bar OR "quoted-phrase"`+ ],['phrase-with-dash* + "quoted-phrase"',- `"phrase-with-dash*" AND "quoted-phrase"`+ `"phrase-with-dash*" AND "+" AND "quoted-phrase"`],['example -foo + bar + "quoted-dash-phrase*" OR "another-quoted-phrase"',- `example AND "-foo" AND bar AND "quoted-dash-phrase*" OR "another-quoted-phrase"`+ `example AND "-foo" AND "+" AND bar AND "+" AND "quoted-dash-phrase*" OR "another-quoted-phrase"`],- ["", ""],+ ["", undefined],["foo", `foo`],['"quoted"', '"quoted"'],["-foo -bar", `"-foo" AND "-bar"`],- ["foo + + bar", `foo AND bar`],- ["foo + OR", `foo`],+ ["foo + + bar", `foo AND "+" AND "+" AND bar`],+ ["foo + OR", `foo AND "+"`],['"special -phrase*"', '"special -phrase*"'],- ["foo* + bar*", `"foo*" AND "bar*"`],- ["(foo + bar) -baz", `"(foo" AND "bar)" AND "-baz"`],+ ["foo* + bar*", `"foo*" AND "+" AND "bar*"`],+ ["(foo + bar) -baz", `"(foo" AND "+" AND "bar)" AND "-baz"`],['"phrase with "quotes""', '"phrase with ""quotes"""'],- ['foo + "bar -baz" OR "qux*"', `foo AND "bar -baz" OR "qux*"`],- ["foo + bar + ", `foo AND bar`],+ ['foo + "bar -baz" OR "qux*"', `foo AND "+" AND "bar -baz" OR "qux*"`],+ ["foo + bar + ", `foo AND "+" AND bar AND "+"`],["+foo bar", `"+foo" AND bar`],["foo*bar*", `"foo*bar*"`],['"escaped "quotes""', '"escaped ""quotes"""'],@@ -65,12 +68,12 @@ const TRANSFORM_QUERY_TESTS: [string, string][] = [["*helo*", `"*helo*"`],[">he", `">he"`],["something<hello", `"something<hello"`],- ["<", ``],- [">", ``]+ ["<", `"<"`],+ [">", `">"`]];for (const [input, expectedOutput] of TRANSFORM_QUERY_TESTS) {test(`should transform "${input}" into a valid SQL query`, () => {- expect(transformQuery(input).query).toBe(expectedOutput);+ expect(transformQuery(input).content?.query).toBe(expectedOutput);});}