From 5ff3b44550d4f5ab9a20d85dbf4387d455ebb862 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 10 Feb 2022 19:52:45 +0100 Subject: idb-bridge: update tests for ava 4.x --- .../idb-bridge/src/idb-wpt-ported/value.test.ts | 72 ++++++++++++---------- 1 file changed, 38 insertions(+), 34 deletions(-) (limited to 'packages/idb-bridge/src/idb-wpt-ported/value.test.ts') diff --git a/packages/idb-bridge/src/idb-wpt-ported/value.test.ts b/packages/idb-bridge/src/idb-wpt-ported/value.test.ts index acae2fe63..a80ec2b5a 100644 --- a/packages/idb-bridge/src/idb-wpt-ported/value.test.ts +++ b/packages/idb-bridge/src/idb-wpt-ported/value.test.ts @@ -1,47 +1,51 @@ import test from "ava"; -import { IDBVersionChangeEvent } from "../idbtypes"; -import { createdb } from "./wptsupport"; +import { IDBVersionChangeEvent } from "../idbtypes.js"; +import { createdb } from "./wptsupport.js"; -test.cb("WPT test value.htm, array", (t) => { - const value = new Array(); - const _instanceof = Array; +test("WPT test value.htm, array", (t) => { + return new Promise((resolve, reject) => { + const value = new Array(); + const _instanceof = Array; - t.plan(1); + t.plan(1); - createdb(t).onupgradeneeded = function (e: IDBVersionChangeEvent) { - (e.target as any).result.createObjectStore("store").add(value, 1); - (e.target as any).onsuccess = (e: any) => { - console.log("in first onsuccess"); - e.target.result - .transaction("store") - .objectStore("store") - .get(1).onsuccess = (e: any) => { - t.assert(e.target.result instanceof _instanceof, "instanceof"); - t.end(); + createdb(t).onupgradeneeded = function (e: IDBVersionChangeEvent) { + (e.target as any).result.createObjectStore("store").add(value, 1); + (e.target as any).onsuccess = (e: any) => { + console.log("in first onsuccess"); + e.target.result + .transaction("store") + .objectStore("store") + .get(1).onsuccess = (e: any) => { + t.assert(e.target.result instanceof _instanceof, "instanceof"); + resolve(); + }; }; }; - }; + }); }); -test.cb("WPT test value.htm, date", (t) => { - const value = new Date(); - const _instanceof = Date; +test("WPT test value.htm, date", (t) => { + return new Promise((resolve, reject) => { + const value = new Date(); + const _instanceof = Date; - t.plan(1); + t.plan(1); - createdb(t).onupgradeneeded = function (e: IDBVersionChangeEvent) { - (e.target as any).result.createObjectStore("store").add(value, 1); - (e.target as any).onsuccess = (e: any) => { - console.log("in first onsuccess"); - e.target.result - .transaction("store") - .objectStore("store") - .get(1).onsuccess = (e: any) => { - console.log("target", e.target); - console.log("result", e.target.result); - t.assert(e.target.result instanceof _instanceof, "instanceof"); - t.end(); + createdb(t).onupgradeneeded = function (e: IDBVersionChangeEvent) { + (e.target as any).result.createObjectStore("store").add(value, 1); + (e.target as any).onsuccess = (e: any) => { + console.log("in first onsuccess"); + e.target.result + .transaction("store") + .objectStore("store") + .get(1).onsuccess = (e: any) => { + console.log("target", e.target); + console.log("result", e.target.result); + t.assert(e.target.result instanceof _instanceof, "instanceof"); + resolve(); + }; }; }; - }; + }); }); -- cgit v1.2.3