diff options
Diffstat (limited to 'packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts')
-rw-r--r-- | packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts | 211 |
1 files changed, 112 insertions, 99 deletions
diff --git a/packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts b/packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts index c4bce8743..db2cdbca8 100644 --- a/packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts +++ b/packages/idb-bridge/src/idb-wpt-ported/cursor-overloads.test.ts @@ -1,117 +1,130 @@ import test from "ava"; -import { BridgeIDBCursor, BridgeIDBKeyRange } from ".."; -import { BridgeIDBCursorWithValue } from "../bridge-idb"; -import { IDBRequest } from "../idbtypes"; -import { createdb } from "./wptsupport"; +import { BridgeIDBKeyRange } from "../bridge-idb.js"; +import { IDBRequest } from "../idbtypes.js"; +import { createdb } from "./wptsupport.js"; const IDBKeyRange = BridgeIDBKeyRange; // Validate the overloads of IDBObjectStore.openCursor(), // IDBIndex.openCursor() and IDBIndex.openKeyCursor() -test.cb("WPT test cursor-overloads.htm", (t) => { - var db: any, store: any, index: any; +test("WPT test cursor-overloads.htm", (t) => { + return new Promise((resolve, reject) => { + var db: any, store: any, index: any; - var request = createdb(t); - request.onupgradeneeded = function (e: any) { - db = request.result; - store = db.createObjectStore("store"); - index = store.createIndex("index", "value"); - store.put({ value: 0 }, 0); - const trans = request.transaction!; - trans.oncomplete = verifyOverloads; - }; + var request = createdb(t); + request.onupgradeneeded = function (e: any) { + db = request.result; + store = db.createObjectStore("store"); + index = store.createIndex("index", "value"); + store.put({ value: 0 }, 0); + const trans = request.transaction!; + trans.oncomplete = verifyOverloads; + }; - async function verifyOverloads() { - const trans = db.transaction("store"); - store = trans.objectStore("store"); - index = store.index("index"); + async function verifyOverloads() { + const trans = db.transaction("store"); + store = trans.objectStore("store"); + index = store.index("index"); - await checkCursorDirection(store.openCursor(), "next"); - await checkCursorDirection(store.openCursor(0), "next"); - await checkCursorDirection(store.openCursor(0, "next"), "next"); - await checkCursorDirection(store.openCursor(0, "nextunique"), "nextunique"); - await checkCursorDirection(store.openCursor(0, "prev"), "prev"); - await checkCursorDirection(store.openCursor(0, "prevunique"), "prevunique"); + await checkCursorDirection(store.openCursor(), "next"); + await checkCursorDirection(store.openCursor(0), "next"); + await checkCursorDirection(store.openCursor(0, "next"), "next"); + await checkCursorDirection( + store.openCursor(0, "nextunique"), + "nextunique", + ); + await checkCursorDirection(store.openCursor(0, "prev"), "prev"); + await checkCursorDirection( + store.openCursor(0, "prevunique"), + "prevunique", + ); - await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next"); - await checkCursorDirection( - store.openCursor(BridgeIDBKeyRange.only(0), "next"), - "next", - ); - await checkCursorDirection( - store.openCursor(IDBKeyRange.only(0), "nextunique"), - "nextunique", - ); - await checkCursorDirection( - store.openCursor(IDBKeyRange.only(0), "prev"), - "prev", - ); - await checkCursorDirection( - store.openCursor(IDBKeyRange.only(0), "prevunique"), - "prevunique", - ); + await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next"); + await checkCursorDirection( + store.openCursor(BridgeIDBKeyRange.only(0), "next"), + "next", + ); + await checkCursorDirection( + store.openCursor(IDBKeyRange.only(0), "nextunique"), + "nextunique", + ); + await checkCursorDirection( + store.openCursor(IDBKeyRange.only(0), "prev"), + "prev", + ); + await checkCursorDirection( + store.openCursor(IDBKeyRange.only(0), "prevunique"), + "prevunique", + ); - await checkCursorDirection(index.openCursor(), "next"); - await checkCursorDirection(index.openCursor(0), "next"); - await checkCursorDirection(index.openCursor(0, "next"), "next"); - await checkCursorDirection(index.openCursor(0, "nextunique"), "nextunique"); - await checkCursorDirection(index.openCursor(0, "prev"), "prev"); - await checkCursorDirection(index.openCursor(0, "prevunique"), "prevunique"); + await checkCursorDirection(index.openCursor(), "next"); + await checkCursorDirection(index.openCursor(0), "next"); + await checkCursorDirection(index.openCursor(0, "next"), "next"); + await checkCursorDirection( + index.openCursor(0, "nextunique"), + "nextunique", + ); + await checkCursorDirection(index.openCursor(0, "prev"), "prev"); + await checkCursorDirection( + index.openCursor(0, "prevunique"), + "prevunique", + ); - await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next"); - await checkCursorDirection( - index.openCursor(IDBKeyRange.only(0), "next"), - "next", - ); - await checkCursorDirection( - index.openCursor(IDBKeyRange.only(0), "nextunique"), - "nextunique", - ); - await checkCursorDirection( - index.openCursor(IDBKeyRange.only(0), "prev"), - "prev", - ); - await checkCursorDirection( - index.openCursor(IDBKeyRange.only(0), "prevunique"), - "prevunique", - ); + await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next"); + await checkCursorDirection( + index.openCursor(IDBKeyRange.only(0), "next"), + "next", + ); + await checkCursorDirection( + index.openCursor(IDBKeyRange.only(0), "nextunique"), + "nextunique", + ); + await checkCursorDirection( + index.openCursor(IDBKeyRange.only(0), "prev"), + "prev", + ); + await checkCursorDirection( + index.openCursor(IDBKeyRange.only(0), "prevunique"), + "prevunique", + ); - await checkCursorDirection(index.openKeyCursor(), "next"); - await checkCursorDirection(index.openKeyCursor(0), "next"); - await checkCursorDirection(index.openKeyCursor(0, "next"), "next"); - await checkCursorDirection( - index.openKeyCursor(0, "nextunique"), - "nextunique", - ); - await checkCursorDirection(index.openKeyCursor(0, "prev"), "prev"); - await checkCursorDirection( - index.openKeyCursor(0, "prevunique"), - "prevunique", - ); + await checkCursorDirection(index.openKeyCursor(), "next"); + await checkCursorDirection(index.openKeyCursor(0), "next"); + await checkCursorDirection(index.openKeyCursor(0, "next"), "next"); + await checkCursorDirection( + index.openKeyCursor(0, "nextunique"), + "nextunique", + ); + await checkCursorDirection(index.openKeyCursor(0, "prev"), "prev"); + await checkCursorDirection( + index.openKeyCursor(0, "prevunique"), + "prevunique", + ); - await checkCursorDirection( - index.openKeyCursor(IDBKeyRange.only(0)), - "next", - ); - await checkCursorDirection( - index.openKeyCursor(IDBKeyRange.only(0), "next"), - "next", - ); - await checkCursorDirection( - index.openKeyCursor(IDBKeyRange.only(0), "nextunique"), - "nextunique", - ); - await checkCursorDirection( - index.openKeyCursor(IDBKeyRange.only(0), "prev"), - "prev", - ); - await checkCursorDirection( - index.openKeyCursor(IDBKeyRange.only(0), "prevunique"), - "prevunique", - ); + await checkCursorDirection( + index.openKeyCursor(IDBKeyRange.only(0)), + "next", + ); + await checkCursorDirection( + index.openKeyCursor(IDBKeyRange.only(0), "next"), + "next", + ); + await checkCursorDirection( + index.openKeyCursor(IDBKeyRange.only(0), "nextunique"), + "nextunique", + ); + await checkCursorDirection( + index.openKeyCursor(IDBKeyRange.only(0), "prev"), + "prev", + ); + await checkCursorDirection( + index.openKeyCursor(IDBKeyRange.only(0), "prevunique"), + "prevunique", + ); - t.end(); - } + resolve(); + } + }); function checkCursorDirection( request: IDBRequest, |