From a6b42d6069853eded0851908a85abfb961bc0980 Mon Sep 17 00:00:00 2001 From: Carson Farmer Date: Thu, 22 Oct 2020 16:21:34 -0700 Subject: [PATCH] fix: proper json output + remote deps Signed-off-by: Carson Farmer --- src/local/collection.spec.ts | 5 +---- src/local/db.ts | 2 +- src/local/document.ts | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/local/collection.spec.ts b/src/local/collection.spec.ts index 91dba1b..f746e57 100644 --- a/src/local/collection.spec.ts +++ b/src/local/collection.spec.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import { expect } from "chai"; -import mingo from "mingo"; import { ulid } from "ulid"; import { Collection } from "./collection"; import { NewDexie } from "../utils"; @@ -330,7 +329,7 @@ describe("collection", function () { // Should be an actual class instance, that we can export to JSON if (personInstance) { const json = personInstance.toJSON(); - expect(json).to.equal(JSON.stringify(person)); + expect(json).to.deep.equal(person); } else { throw new Error("should not be undefined"); } @@ -508,8 +507,6 @@ describe("collection", function () { expect(last?.age).to.be.greaterThan(5); expect(last?.age).to.be.lessThan(56); expect(await Person.find().count()).to.equal(7); - // Use mingo directly, should also return 3 (sanity check) - expect(mingo.find(people, query).count()).to.equal(3); }); }); diff --git a/src/local/db.ts b/src/local/db.ts index 891d8ba..0891f9c 100644 --- a/src/local/db.ts +++ b/src/local/db.ts @@ -1,5 +1,5 @@ import { Collection, CollectionConfig } from "./collection"; -import { createIndexString, hashString, NewDexie } from "../utils"; +import { createIndexString, NewDexie } from "../utils"; import { Remote } from "../remote"; import { Dexie, Table } from "dexie"; diff --git a/src/local/document.ts b/src/local/document.ts index 8af7593..da102a4 100644 --- a/src/local/document.ts +++ b/src/local/document.ts @@ -71,7 +71,8 @@ export function DocumentInstanceClassFactory( * Get a JSON representation of this instance. */ toJSON(): JSONType { - return JSON.stringify({ ...this }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return { ...(this as any) }; } }; return cls as DocumentInstanceConstructor;