diff options
author | Florian Dold <florian@dold.me> | 2023-07-11 15:41:48 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-08-22 08:01:13 +0200 |
commit | b2d0ad57ddf251a109d536cdc49fb6505dbdc50c (patch) | |
tree | 7eaeca3ad8ec97a9c1970c1004feda2d61c3441b /packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts | |
parent | 58fdf9dc091b076787a9746c405fe6a9366f5da6 (diff) | |
download | wallet-core-b2d0ad57ddf251a109d536cdc49fb6505dbdc50c.tar.xz |
sqlite3 backend for idb-bridge / wallet-core
Diffstat (limited to 'packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts')
-rw-r--r-- | packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts index 02618f171..b8046fc1b 100644 --- a/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts +++ b/packages/idb-bridge/src/idb-wpt-ported/idbfactory-open.test.ts @@ -1,7 +1,10 @@ import test from "ava"; import { BridgeIDBVersionChangeEvent } from "../bridge-idb.js"; import FakeEvent from "../util/FakeEvent.js"; -import { createdb, format_value, idbFactory } from "./wptsupport.js"; +import { createdb, format_value, initTestIndexedDB, useTestIndexedDb } from "./wptsupport.js"; +import { IDBDatabase } from "../idbtypes.js"; + +test.before("test DB initialization", initTestIndexedDB); // IDBFactory.open() - request has no source test("WPT idbfactory-open.htm", async (t) => { @@ -36,7 +39,7 @@ test("WPT idbfactory-open2.htm", async (t) => { // IDBFactory.open() - no version opens current database test("WPT idbfactory-open3.htm", async (t) => { - const indexedDB = idbFactory; + const indexedDB = useTestIndexedDb(); await new Promise<void>((resolve, reject) => { var open_rq = createdb(t, undefined, 13); var did_upgrade = false; @@ -61,7 +64,6 @@ test("WPT idbfactory-open3.htm", async (t) => { // IDBFactory.open() - new database has default version test("WPT idbfactory-open4.htm", async (t) => { - const indexedDB = idbFactory; await new Promise<void>((resolve, reject) => { var open_rq = createdb(t, t.title + "-database_name"); @@ -78,7 +80,6 @@ test("WPT idbfactory-open4.htm", async (t) => { // IDBFactory.open() - new database is empty test("WPT idbfactory-open5.htm", async (t) => { - const indexedDB = idbFactory; await new Promise<void>((resolve, reject) => { var open_rq = createdb(t, t.title + "-database_name"); @@ -97,7 +98,7 @@ test("WPT idbfactory-open5.htm", async (t) => { // IDBFactory.open() - open database with a lower version than current test("WPT idbfactory-open6.htm", async (t) => { - const indexedDB = idbFactory; + const indexedDB = useTestIndexedDb(); await new Promise<void>((resolve, reject) => { var open_rq = createdb(t, undefined, 13); var open_rq2: any; @@ -131,7 +132,7 @@ test("WPT idbfactory-open6.htm", async (t) => { // IDBFactory.open() - open database with a higher version than current test("WPT idbfactory-open7.htm", async (t) => { - const indexedDB = idbFactory; + const indexedDB = useTestIndexedDb(); await new Promise<void>((resolve, reject) => { var open_rq = createdb(t, undefined, 13); var did_upgrade = false; @@ -169,7 +170,7 @@ test("WPT idbfactory-open7.htm", async (t) => { // IDBFactory.open() - error in version change transaction aborts open test("WPT idbfactory-open8.htm", async (t) => { - const indexedDB = idbFactory; + const indexedDB = useTestIndexedDb(); await new Promise<void>((resolve, reject) => { var open_rq = createdb(t, undefined, 13); var did_upgrade = false; @@ -193,7 +194,7 @@ test("WPT idbfactory-open8.htm", async (t) => { // IDBFactory.open() - errors in version argument test("WPT idbfactory-open9.htm", async (t) => { - const indexedDB = idbFactory; + const indexedDB = useTestIndexedDb(); function should_throw(val: any, name?: string) { if (!name) { name = typeof val == "object" && val ? "object" : format_value(val); @@ -281,9 +282,9 @@ test("WPT idbfactory-open9.htm", async (t) => { // IDBFactory.open() - error in version change transaction aborts open test("WPT idbfactory-open10.htm", async (t) => { - const indexedDB = idbFactory; + const indexedDB = useTestIndexedDb(); await new Promise<void>((resolve, reject) => { - var db: any, db2: any; + var db: IDBDatabase, db2: IDBDatabase; var open_rq = createdb(t, undefined, 9); open_rq.onupgradeneeded = function (e: any) { @@ -350,7 +351,7 @@ test("WPT idbfactory-open10.htm", async (t) => { var open_rq3 = indexedDB.open(db.name); open_rq3.onsuccess = function (e: any) { - var db3 = e.target.result; + var db3: IDBDatabase = e.target.result; t.true( db3.objectStoreNames.contains("store"), @@ -407,7 +408,7 @@ test("WPT idbfactory-open10.htm", async (t) => { // IDBFactory.open() - second open's transaction is available to get objectStores test("WPT idbfactory-open11.htm", async (t) => { - const indexedDB = idbFactory; + const indexedDB = useTestIndexedDb(); await new Promise<void>((resolve, reject) => { var db: any; var count_done = 0; @@ -472,8 +473,6 @@ test("WPT idbfactory-open11.htm", async (t) => { // IDBFactory.open() - upgradeneeded gets VersionChangeEvent test("WPT idbfactory-open12.htm", async (t) => { - const indexedDB = idbFactory; - var db: any; var open_rq = createdb(t, undefined, 9); |