wallet-core/packages/idb-bridge/src/idb-wpt-ported/value.test.ts

52 lines
1.5 KiB
TypeScript
Raw Normal View History

import test from "ava";
2022-02-10 19:52:45 +01:00
import { IDBVersionChangeEvent } from "../idbtypes.js";
import { createdb } from "./wptsupport.js";
2022-02-10 19:52:45 +01:00
test("WPT test value.htm, array", (t) => {
return new Promise((resolve, reject) => {
const value = new Array();
const _instanceof = Array;
2022-02-10 19:52:45 +01:00
t.plan(1);
2022-02-10 19:52:45 +01:00
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();
};
};
};
2022-02-10 19:52:45 +01:00
});
});
2022-02-10 19:52:45 +01:00
test("WPT test value.htm, date", (t) => {
return new Promise((resolve, reject) => {
const value = new Date();
const _instanceof = Date;
2022-02-10 19:52:45 +01:00
t.plan(1);
2022-02-10 19:52:45 +01:00
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();
};
};
};
2022-02-10 19:52:45 +01:00
});
});