Basic draft library #19
3 changed files with 17 additions and 4 deletions
|
@ -20,8 +20,10 @@ class CardDatabase extends Dexie {
|
|||
export let Database: CardDatabase | null = null;
|
||||
|
||||
export function initDB() {
|
||||
if (Database == null) {
|
||||
Database = new CardDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
export async function getCards(filter: CardFilter) {
|
||||
if (Database == null) {
|
||||
|
|
11
src/testing/IDBShim.ts
Normal file
11
src/testing/IDBShim.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import Dexie from "dexie";
|
||||
|
||||
let init = false;
|
||||
|
||||
export function setupIDBShim() {
|
||||
if (!init) {
|
||||
const setGlobalVars = require("indexeddbshim");
|
||||
setGlobalVars(Dexie.dependencies);
|
||||
init = true;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import { loadSets, getCards, Database, initDB, cardFullName } from "@/mlpccg";
|
||||
import Dexie from "dexie";
|
||||
const setGlobalVars = require("indexeddbshim");
|
||||
setGlobalVars(Dexie.dependencies);
|
||||
import { setupIDBShim } from "@/testing/IDBShim";
|
||||
|
||||
setupIDBShim();
|
||||
|
||||
describe("mlpccg/Database", () => {
|
||||
beforeAll(async () => {
|
||||
|
|
Loading…
Reference in a new issue