summaryrefslogtreecommitdiff
path: root/packages/idb-bridge/src/idb-wpt-ported/idbfactory-cmp.test.ts
blob: c7a25a46b921b9e644a3a319ed26afe55703dad2 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import test from "ava";
import { createdb, idbFactory } from "./wptsupport";

test("WPT idbfactory-cmp*.html", async (t) => {
  const indexedDB = idbFactory;
  var greater = indexedDB.cmp(2, 1);
  var equal = indexedDB.cmp(2, 2);
  var less = indexedDB.cmp(1, 2);

  t.deepEqual(greater, 1, "greater");
  t.deepEqual(equal, 0, "equal");
  t.deepEqual(less, -1, "less");

  t.throws(
    () => {
      // @ts-expect-error
      indexedDB.cmp();
    },
    { instanceOf: TypeError },
  );

  t.throws(
    () => {
      indexedDB.cmp(null, null);
    },
    { name: "DataError" },
  );

  t.throws(
    () => {
      indexedDB.cmp(1, null);
    },
    { name: "DataError" },
  );

  t.throws(
    () => {
      indexedDB.cmp(null, 1);
    },
    { name: "DataError" },
  );

  t.throws(
    () => {
      indexedDB.cmp(NaN, NaN);
    },
    { name: "DataError" },
  );

  t.throws(
    () => {
      indexedDB.cmp(1, NaN);
    },
    { name: "DataError" },
  );

  t.throws(
    () => {
      indexedDB.cmp(NaN, 1);
    },
    { name: "DataError" },
  );
});