Only initialize IDBShim and database once
This commit is contained in:
parent
e238485b21
commit
cf47d5db4a
3 changed files with 17 additions and 4 deletions
|
@ -20,7 +20,9 @@ class CardDatabase extends Dexie {
|
||||||
export let Database: CardDatabase | null = null;
|
export let Database: CardDatabase | null = null;
|
||||||
|
|
||||||
export function initDB() {
|
export function initDB() {
|
||||||
Database = new CardDatabase();
|
if (Database == null) {
|
||||||
|
Database = new CardDatabase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCards(filter: CardFilter) {
|
export async function getCards(filter: CardFilter) {
|
||||||
|
|
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 { loadSets, getCards, Database, initDB, cardFullName } from "@/mlpccg";
|
||||||
import Dexie from "dexie";
|
import { setupIDBShim } from "@/testing/IDBShim";
|
||||||
const setGlobalVars = require("indexeddbshim");
|
|
||||||
setGlobalVars(Dexie.dependencies);
|
setupIDBShim();
|
||||||
|
|
||||||
describe("mlpccg/Database", () => {
|
describe("mlpccg/Database", () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
|
Loading…
Reference in a new issue