Commit 2f255abb authored by Romain Courteaud's avatar Romain Courteaud

idb: check capacity

parent 8ecb7533
...@@ -64,10 +64,7 @@ ...@@ -64,10 +64,7 @@
} }
IndexedDBStorage.prototype.hasCapacity = function (name) { IndexedDBStorage.prototype.hasCapacity = function (name) {
if (name === "subquery") { return ((name === "list") || (name === "include"));
return this._index_keys;
}
return ((name === "list") || (name === "include")) || (name === "subquery");
}; };
function buildKeyPath(key_list) { function buildKeyPath(key_list) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
deepEqual = QUnit.deepEqual, deepEqual = QUnit.deepEqual,
equal = QUnit.equal, equal = QUnit.equal,
module = QUnit.module, module = QUnit.module,
throws = QUnit.throws,
big_string = "", big_string = "",
j; j;
...@@ -244,12 +245,35 @@ ...@@ -244,12 +245,35 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
module("indexeddbStorage.hasCapacity"); module("indexeddbStorage.hasCapacity");
test("can list documents", function () { test("can list documents", function () {
expect(2);
var jio = jIO.createJIO({ var jio = jIO.createJIO({
type: "indexeddb", type: "indexeddb",
database: "qunit" database: "qunit"
}); });
ok(jio.hasCapacity("list")); ok(jio.hasCapacity("list"));
ok(jio.hasCapacity("include"));
});
test("can not search documents", function () {
expect(4);
var jio = jIO.createJIO({
type: "indexeddb",
database: "qunit"
});
throws(
function () {
jio.hasCapacity("query");
},
function (error) {
ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 501);
equal(error.message,
"Capacity 'query' is not implemented on 'indexeddb'");
return true;
}
);
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment