[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: more WPTs
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: more WPTs |
Date: |
Thu, 18 Feb 2021 11:15:36 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new fe1b9efa more WPTs
fe1b9efa is described below
commit fe1b9efae56b093bf9cb7c27bce7252623a04a20
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Feb 18 11:15:25 2021 +0100
more WPTs
---
.../idb-wpt-ported/idbcursor-advance-index.test.ts | 57 ++++++++++++++++++++++
.../idbcursor-continue-index.test.ts | 46 +++++++++++++++++
2 files changed, 103 insertions(+)
diff --git
a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-advance-index.test.ts
b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-advance-index.test.ts
new file mode 100644
index 00000000..a7be31f2
--- /dev/null
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-advance-index.test.ts
@@ -0,0 +1,57 @@
+import test from "ava";
+import { BridgeIDBCursor } from "..";
+import { createdb } from "./wptsupport";
+
+test("WPT test idbcursor_advance_index.htm", async (t) => {
+ await new Promise<void>((resolve, reject) => {
+ let db: any;
+ let count = 0;
+ const records = [
+ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ { pKey: "primaryKey_2", iKey: "indexKey_2" },
+ { pKey: "primaryKey_3", iKey: "indexKey_3" },
+ ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function (e: any) {
+ db = e.target.result;
+ var store = db.createObjectStore("test", { keyPath: "pKey" });
+ store.createIndex("idx", "iKey");
+
+ for (var i = 0; i < records.length; i++) {
+ store.add(records[i]);
+ }
+ };
+
+ open_rq.onsuccess = function (e) {
+ var cursor_rq = db
+ .transaction("test")
+ .objectStore("test")
+ .index("idx")
+ .openCursor();
+
+ cursor_rq.onsuccess = function (e: any) {
+ var cursor = e.target.result;
+ t.log(cursor);
+ t.true(cursor instanceof BridgeIDBCursor);
+
+ switch (count) {
+ case 0:
+ count += 3;
+ cursor.advance(3);
+ break;
+ case 3:
+ var record = cursor.value;
+ t.deepEqual(record.pKey, records[count].pKey, "record.pKey");
+ t.deepEqual(record.iKey, records[count].iKey, "record.iKey");
+ resolve();
+ break;
+ default:
+ t.fail("unexpected count");
+ break;
+ }
+ }
+ };
+ });
+});
diff --git
a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-index.test.ts
b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-index.test.ts
new file mode 100644
index 00000000..040fb75f
--- /dev/null
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-index.test.ts
@@ -0,0 +1,46 @@
+import test from "ava";
+import { BridgeIDBCursor } from "..";
+import { createdb } from "./wptsupport";
+
+test("WPT test idbcursor_continue_index.htm", async (t) => {
+ await new Promise<void>((resolve, reject) => {
+ var db: any;
+ let count = 0;
+ const records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
+ { pKey: "primaryKey_1", iKey: "indexKey_1" },
+ { pKey: "primaryKey_1-2", iKey: "indexKey_1" } ];
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function(e: any) {
+ db = e.target.result;
+ var objStore = db.createObjectStore("test", { keyPath:"pKey" });
+
+ objStore.createIndex("index", "iKey");
+
+ for (var i = 0; i < records.length; i++)
+ objStore.add(records[i]);
+ };
+
+ open_rq.onsuccess = function(e) {
+ var cursor_rq = db.transaction("test")
+ .objectStore("test")
+ .index("index")
+ .openCursor();
+
+ cursor_rq.onsuccess = function(e: any) {
+ var cursor = e.target.result;
+ if (!cursor) {
+ t.deepEqual(count, records.length, "cursor run count");
+ resolve();
+ }
+
+ var record = cursor.value;
+ t.deepEqual(record.pKey, records[count].pKey, "primary key");
+ t.deepEqual(record.iKey, records[count].iKey, "index key");
+
+ cursor.continue();
+ count++;
+ };
+ };
+ });
+});
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.