feat: 2.0.0 beta release
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { IndexedDbCache } from "../src/Databases/IndexedDb.Cache.js";
|
||||
import { Options } from "../src/index.js";
|
||||
import { WithId } from "../src/Types.js";
|
||||
import { afterEach, beforeEach, describe, it } from "@std/testing/bdd";
|
||||
import { expect } from "expect";
|
||||
|
||||
import { IndexedDbCache } from "../src/databases/indexeddb/cache.ts";
|
||||
import { Options } from "../src/storage/storage.ts";
|
||||
import type { WithId } from "../src/types.ts";
|
||||
|
||||
describe("IndexedDbCache", () => {
|
||||
let cache: IndexedDbCache;
|
||||
@@ -15,31 +18,31 @@ describe("IndexedDbCache", () => {
|
||||
|
||||
const sampleDocuments: WithId<{ name: string }>[] = [
|
||||
{ id: "doc1", name: "Document 1" },
|
||||
{ id: "doc2", name: "Document 2" }
|
||||
{ id: "doc2", name: "Document 2" },
|
||||
];
|
||||
|
||||
const sampleCriteria = { name: { $eq: "Document 1" } };
|
||||
const sampleOptions: Options = { sort: { name: 1 } };
|
||||
|
||||
test("hash", () => {
|
||||
it("hash", () => {
|
||||
const hashCode = cache.hash(sampleCriteria, sampleOptions);
|
||||
expect(typeof hashCode).toBe("number");
|
||||
});
|
||||
|
||||
test("set and get", () => {
|
||||
it("set and get", () => {
|
||||
const hashCode = cache.hash(sampleCriteria, sampleOptions);
|
||||
cache.set(hashCode, sampleDocuments);
|
||||
const result = cache.get(hashCode);
|
||||
expect(result).toEqual(sampleDocuments);
|
||||
});
|
||||
|
||||
test("get undefined", () => {
|
||||
it("get undefined", () => {
|
||||
const hashCode = cache.hash(sampleCriteria, sampleOptions);
|
||||
const result = cache.get(hashCode);
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
test("flush", () => {
|
||||
it("flush", () => {
|
||||
const hashCode = cache.hash(sampleCriteria, sampleOptions);
|
||||
cache.set(hashCode, sampleDocuments);
|
||||
cache.flush();
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Collection } from "../src/Collection.js";
|
||||
import { MemoryStorage } from "../src/Databases/MemoryDb.Storage.js";
|
||||
import { getUsers, UserDocument } from "./Users.Mock.js";
|
||||
import { describe, it } from "@std/testing/bdd";
|
||||
import { expect } from "expect";
|
||||
|
||||
import { Collection } from "../src/collection.ts";
|
||||
import { MemoryStorage } from "../src/databases/memory/storage.ts";
|
||||
import { getUsers, UserDocument } from "./users.mock.ts";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------
|
||||
@@ -1,11 +1,14 @@
|
||||
import { hashCodeQuery } from "../src/Hash.js";
|
||||
import { Options } from "../src/index.js";
|
||||
import { describe, it } from "@std/testing/bdd";
|
||||
import { expect } from "expect";
|
||||
|
||||
import { hashCodeQuery } from "../src/hash.ts";
|
||||
import { Options } from "../src/mod.ts";
|
||||
|
||||
describe("hashCodeQuery", () => {
|
||||
const filter = { name: { $eq: "Document 1" } };
|
||||
const options: Options = { sort: { name: 1 } };
|
||||
|
||||
test("return correct hash code", () => {
|
||||
it("return correct hash code", () => {
|
||||
const hashCode = hashCodeQuery(filter, options);
|
||||
expect(typeof hashCode).toBe("number");
|
||||
});
|
||||
@@ -1,7 +1,12 @@
|
||||
import { Collection } from "../src/Collection.js";
|
||||
import { MemoryStorage } from "../src/Databases/MemoryDb.Storage.js";
|
||||
import { DuplicateDocumentError } from "../src/index.js";
|
||||
import { getUsers } from "./Users.Mock.js";
|
||||
import "fake-indexeddb/auto";
|
||||
|
||||
import { describe, it } from "@std/testing/bdd";
|
||||
import { expect } from "expect";
|
||||
|
||||
import { Collection } from "../src/collection.ts";
|
||||
import { MemoryStorage } from "../src/databases/memory/storage.ts";
|
||||
import { DuplicateDocumentError } from "../src/storage/errors.ts";
|
||||
import { getUsers } from "./users.mock.ts";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Collection } from "../src/Collection.js";
|
||||
import { MemoryStorage } from "../src/Databases/MemoryDb.Storage.js";
|
||||
import { RemoveResult } from "../src/index.js";
|
||||
import { getUsers } from "./Users.Mock.js";
|
||||
import { describe, it } from "@std/testing/bdd";
|
||||
import { expect } from "expect";
|
||||
|
||||
import { Collection } from "../src/collection.ts";
|
||||
import { MemoryStorage } from "../src/databases/memory/storage.ts";
|
||||
import { RemoveResult } from "../src/storage/operators/remove.ts";
|
||||
import { getUsers } from "./users.mock.ts";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
import { clone } from "../src/Clone.js";
|
||||
import { WithId } from "../src/Types.js";
|
||||
import { clone } from "../src/clone.ts";
|
||||
import { WithId } from "../src/types.ts";
|
||||
|
||||
const users: WithId<UserDocument>[] = [
|
||||
{
|
||||
@@ -9,10 +9,10 @@ const users: WithId<UserDocument>[] = [
|
||||
friends: [
|
||||
{
|
||||
id: "user-2",
|
||||
alias: "Jane"
|
||||
}
|
||||
alias: "Jane",
|
||||
},
|
||||
],
|
||||
interests: ["movies", "tv", "sports"]
|
||||
interests: ["movies", "tv", "sports"],
|
||||
},
|
||||
{
|
||||
id: "user-2",
|
||||
@@ -21,11 +21,11 @@ const users: WithId<UserDocument>[] = [
|
||||
friends: [
|
||||
{
|
||||
id: "user-1",
|
||||
alias: "John"
|
||||
}
|
||||
alias: "John",
|
||||
},
|
||||
],
|
||||
interests: ["movies", "fitness", "dance"]
|
||||
}
|
||||
interests: ["movies", "fitness", "dance"],
|
||||
},
|
||||
];
|
||||
|
||||
export function getUsers(): WithId<UserDocument>[] {
|
||||
Reference in New Issue
Block a user