summaryrefslogtreecommitdiff
path: root/packages/idb-bridge/src/idb-wpt-ported/value.test.ts
blob: c4a8315c6ee35a00c2a2c58eff5949570f8d6cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import test from "ava";
import { IDBVersionChangeEvent } from "../idbtypes";
import { createdb } from "./wptsupport";

test.cb("WPT test value.htm, array", (t) => {
  const value = new Array();
  const _instanceof = Array;

  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();
      };
    };
  };
});

test.cb("WPT test value.htm, date", (t) => {
    const value = new Date();
    const _instanceof = Date;
  
    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();
        };
      };
    };
  });