Skip to content

Commit

Permalink
repro
Browse files Browse the repository at this point in the history
  • Loading branch information
staff0rd committed May 12, 2021
1 parent f76fe35 commit 9f6cb64
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
72 changes: 72 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"@types/node": "^12.20.12",
"@types/react": "^17.0.5",
"@types/react-dom": "^17.0.4",
"dexie": "^3.1.0-alpha.10",
"fake-indexeddb": "^3.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
Expand Down
29 changes: 29 additions & 0 deletions src/db.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Dexie, { DexieOptions } from "dexie";
import indexedDB from "fake-indexeddb";
import IDBKeyRange from "fake-indexeddb/lib/FDBKeyRange";

interface IMessage {
id?: number;
message: string;
}
class TestDatabase extends Dexie {
messages: Dexie.Table<IMessage, number>;

constructor(options?: DexieOptions) {
super("Database", options);
this.version(1).stores({
messages: "++id",
});
this.messages = this.table("messages");
}
}

test("should pass", async () => {
const db = new TestDatabase({
indexedDB: indexedDB,
IDBKeyRange: IDBKeyRange,
});
const result = await db.messages.put({ message: "a message" });
console.warn(result);
expect(result).not.toBeUndefined();
});
2 changes: 2 additions & 0 deletions src/fake-indexeddb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module "fake-indexeddb";
declare module "fake-indexeddb/lib/FDBKeyRange";

0 comments on commit 9f6cb64

Please sign in to comment.