Commit 19a104f5 authored by preetwinder's avatar preetwinder

use consistent string format

parent 591fc12f
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
} }
IndexStorage2.prototype.hasCapacity = function (name) { IndexStorage2.prototype.hasCapacity = function (name) {
return (name === 'query') || (name === 'limit') || (name === 'list') || return (name === "query") || (name === "limit") || (name === "list") ||
this._sub_storage.hasCapacity(name); this._sub_storage.hasCapacity(name);
}; };
...@@ -270,10 +270,10 @@ ...@@ -270,10 +270,10 @@
signature_storage_name) { signature_storage_name) {
var db = evt.target.result, store, i, current_indices, required_indices; var db = evt.target.result, store, i, current_indices, required_indices;
required_indices = new Set(index_keys.map(function (name) { required_indices = new Set(index_keys.map(function (name) {
return 'Index-' + name; return "Index-" + name;
})); }));
if (db.objectStoreNames[0] === 'index-store') { if (db.objectStoreNames[0] === "index-store") {
store = evt.target.transaction.objectStore('index-store'); store = evt.target.transaction.objectStore("index-store");
} }
current_indices = new Set(store ? store.indexNames : []); current_indices = new Set(store ? store.indexNames : []);
...@@ -287,16 +287,16 @@ ...@@ -287,16 +287,16 @@
} }
} else { } else {
if (store) { if (store) {
db.deleteObjectStore('index-store'); db.deleteObjectStore("index-store");
current_indices.clear(); current_indices.clear();
} }
store = db.createObjectStore('index-store', { store = db.createObjectStore("index-store", {
keyPath: 'id', keyPath: "id",
autoIncrement: false autoIncrement: false
}); });
for (i = 0; i < index_keys.length; i += 1) { for (i = 0; i < index_keys.length; i += 1) {
store.createIndex('Index-' + index_keys[i], store.createIndex("Index-" + index_keys[i],
'doc.' + index_keys[i], { unique: false }); "doc." + index_keys[i], { unique: false });
} }
return repairInTransaction(sub_storage_description, return repairInTransaction(sub_storage_description,
evt.target.transaction, index_keys, signature_storage_name, true); evt.target.transaction, index_keys, signature_storage_name, true);
...@@ -429,7 +429,7 @@ ...@@ -429,7 +429,7 @@
if (options.query && !options.include_docs && !options.sort_on && if (options.query && !options.include_docs && !options.sort_on &&
!options.select_list) { !options.select_list) {
query = parseStringToObject(options.query); query = parseStringToObject(options.query);
if (query.type === 'simple') { if (query.type === "simple") {
if (context._index_keys.indexOf(query.key) !== -1) { if (context._index_keys.indexOf(query.key) !== -1) {
return context._runQuery(query.key, query.value, options.limit) return context._runQuery(query.key, query.value, options.limit)
.then(function (result) { .then(function (result) {
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
function DummyStorage3() { function DummyStorage3() {
return this; return this;
} }
jIO.addStorage('dummystorage3', DummyStorage3); jIO.addStorage("dummystorage3", DummyStorage3);
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// indexStorage2.constructor // indexStorage2.constructor
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
module("indexStorage2.buildQuery", { module("indexStorage2.buildQuery", {
setup: function () { setup: function () {
DummyStorage3.prototype.hasCapacity = function (name) { DummyStorage3.prototype.hasCapacity = function (name) {
return (name === 'list') || (name === 'include') || (name === 'select'); return (name === "list") || (name === "include") || (name === "select");
}; };
DummyStorage3.prototype.buildQuery = function () { DummyStorage3.prototype.buildQuery = function () {
return []; return [];
...@@ -546,7 +546,7 @@ ...@@ -546,7 +546,7 @@
}; };
DummyStorage3.prototype.hasCapacity = function (name) { DummyStorage3.prototype.hasCapacity = function (name) {
return (name === 'list') || (name === 'select'); return (name === "list") || (name === "select");
}; };
DummyStorage3.prototype.put = function (id, value) { DummyStorage3.prototype.put = function (id, value) {
fake_data[id] = value; fake_data[id] = value;
...@@ -599,7 +599,7 @@ ...@@ -599,7 +599,7 @@
return id; return id;
}; };
DummyStorage3.prototype.hasCapacity = function (capacity) { DummyStorage3.prototype.hasCapacity = function (capacity) {
return (capacity === 'list') || (capacity === 'query'); return (capacity === "list") || (capacity === "query");
}; };
DummyStorage3.prototype.buildQuery = function (options) { DummyStorage3.prototype.buildQuery = function (options) {
equal(options.query, 'a: "5"'); equal(options.query, 'a: "5"');
...@@ -693,7 +693,7 @@ ...@@ -693,7 +693,7 @@
throw new jIO.util.jIOError("Cannot find document: " + id, 404); throw new jIO.util.jIOError("Cannot find document: " + id, 404);
}; };
DummyStorage3.prototype.hasCapacity = function (name) { DummyStorage3.prototype.hasCapacity = function (name) {
return (name === 'list') || (name === 'include') || (name === 'select'); return (name === "list") || (name === "include") || (name === "select");
}; };
DummyStorage3.prototype.buildQuery = function () { DummyStorage3.prototype.buildQuery = function () {
return Object.values(dummy_data); return Object.values(dummy_data);
...@@ -804,7 +804,7 @@ ...@@ -804,7 +804,7 @@
DummyStorage3.prototype.buildQuery = undefined; DummyStorage3.prototype.buildQuery = undefined;
context.jio.allDocs({query: 'c: "control"'}) context.jio.allDocs({query: "c: 'control'"})
.fail(function (error) { .fail(function (error) {
equal(error, "Connection to: jio:index2_test failed: Version change " + equal(error, "Connection to: jio:index2_test failed: Version change " +
"transaction was aborted in upgradeneeded event handler. " + "transaction was aborted in upgradeneeded event handler. " +
...@@ -836,7 +836,7 @@ ...@@ -836,7 +836,7 @@
}; };
DummyStorage3.prototype.hasCapacity = function (name) { DummyStorage3.prototype.hasCapacity = function (name) {
return (name === 'list') || (name === 'select'); return (name === "list") || (name === "select");
}; };
DummyStorage3.prototype.put = function (id, value) { DummyStorage3.prototype.put = function (id, value) {
fake_data[id] = value; fake_data[id] = value;
...@@ -1116,7 +1116,7 @@ ...@@ -1116,7 +1116,7 @@
}; };
DummyStorage3.prototype.hasCapacity = function (name) { DummyStorage3.prototype.hasCapacity = function (name) {
return (name === 'list') || (name === 'include') || (name === 'select'); return (name === "list") || (name === "include") || (name === "select");
}; };
DummyStorage3.prototype.buildQuery = function () { DummyStorage3.prototype.buildQuery = function () {
...@@ -1130,7 +1130,7 @@ ...@@ -1130,7 +1130,7 @@
]) ])
.then(function () { .then(function () {
return new RSVP.Promise(function (resolve) { return new RSVP.Promise(function (resolve) {
request = indexedDB.open('jio:index2_test'); request = indexedDB.open("jio:index2_test");
request.onsuccess = function () { request.onsuccess = function () {
resolve(request.result); resolve(request.result);
}; };
...@@ -1138,17 +1138,17 @@ ...@@ -1138,17 +1138,17 @@
}) })
.then(function (result) { .then(function (result) {
equal(result.version, 1); equal(result.version, 1);
equal(result.name, 'jio:index2_test'); equal(result.name, "jio:index2_test");
equal(result.objectStoreNames.length, 1); equal(result.objectStoreNames.length, 1);
equal(result.objectStoreNames[0], 'index-store'); equal(result.objectStoreNames[0], "index-store");
store = result.transaction('index-store').objectStore('index-store'); store = result.transaction("index-store").objectStore("index-store");
equal(store.indexNames.length, 2); equal(store.indexNames.length, 2);
equal(store.keyPath, "id"); equal(store.keyPath, "id");
deepEqual(Array.from(store.indexNames).sort(), ['Index-a', 'Index-b']); deepEqual(Array.from(store.indexNames).sort(), ["Index-a", "Index-b"]);
equal(store.index('Index-a').keyPath, 'doc.a'); equal(store.index("Index-a").keyPath, "doc.a");
equal(store.index('Index-b').keyPath, 'doc.b'); equal(store.index("Index-b").keyPath, "doc.b");
equal(store.index('Index-a').unique, false); equal(store.index("Index-a").unique, false);
equal(store.index('Index-b').unique, false); equal(store.index("Index-b").unique, false);
return new RSVP.Promise(function (resolve) { return new RSVP.Promise(function (resolve) {
records = store.getAll(); records = store.getAll();
records.onsuccess = function () { records.onsuccess = function () {
...@@ -1208,7 +1208,7 @@ ...@@ -1208,7 +1208,7 @@
}; };
DummyStorage3.prototype.hasCapacity = function (name) { DummyStorage3.prototype.hasCapacity = function (name) {
return (name === 'list') || (name === 'include') || (name === 'select'); return (name === "list") || (name === "include") || (name === "select");
}; };
DummyStorage3.prototype.buildQuery = function () { DummyStorage3.prototype.buildQuery = function () {
...@@ -1222,7 +1222,7 @@ ...@@ -1222,7 +1222,7 @@
]) ])
.then(function () { .then(function () {
return new RSVP.Promise(function (resolve) { return new RSVP.Promise(function (resolve) {
request = indexedDB.open('jio:index2_test'); request = indexedDB.open("jio:index2_test");
request.onsuccess = function () { request.onsuccess = function () {
resolve(request.result); resolve(request.result);
}; };
...@@ -1230,17 +1230,17 @@ ...@@ -1230,17 +1230,17 @@
}) })
.then(function (result) { .then(function (result) {
equal(result.version, 1); equal(result.version, 1);
equal(result.name, 'jio:index2_test'); equal(result.name, "jio:index2_test");
equal(result.objectStoreNames.length, 1); equal(result.objectStoreNames.length, 1);
equal(result.objectStoreNames[0], 'index-store'); equal(result.objectStoreNames[0], "index-store");
store = result.transaction('index-store').objectStore('index-store'); store = result.transaction("index-store").objectStore("index-store");
equal(store.indexNames.length, 2); equal(store.indexNames.length, 2);
equal(store.keyPath, "id"); equal(store.keyPath, "id");
deepEqual(Array.from(store.indexNames).sort(), ['Index-a', 'Index-b']); deepEqual(Array.from(store.indexNames).sort(), ["Index-a", "Index-b"]);
equal(store.index('Index-a').keyPath, 'doc.a'); equal(store.index("Index-a").keyPath, "doc.a");
equal(store.index('Index-b').keyPath, 'doc.b'); equal(store.index("Index-b").keyPath, "doc.b");
equal(store.index('Index-a').unique, false); equal(store.index("Index-a").unique, false);
equal(store.index('Index-b').unique, false); equal(store.index("Index-b").unique, false);
return new RSVP.Promise(function (resolve) { return new RSVP.Promise(function (resolve) {
records = store.getAll(); records = store.getAll();
records.onsuccess = function () { records.onsuccess = function () {
...@@ -1302,14 +1302,14 @@ ...@@ -1302,14 +1302,14 @@
]) ])
.then(function () { .then(function () {
return new RSVP.Promise(function (resolve) { return new RSVP.Promise(function (resolve) {
request = indexedDB.open('jio:index2_test'); request = indexedDB.open("jio:index2_test");
request.onsuccess = function () { request.onsuccess = function () {
resolve(request.result); resolve(request.result);
}; };
}); });
}) })
.then(function (result) { .then(function (result) {
store = result.transaction('index-store').objectStore('index-store'); store = result.transaction("index-store").objectStore("index-store");
return new RSVP.Promise(function (resolve) { return new RSVP.Promise(function (resolve) {
records = store.getAll(); records = store.getAll();
records.onsuccess = function () { records.onsuccess = function () {
...@@ -1328,8 +1328,8 @@ ...@@ -1328,8 +1328,8 @@
return context.jio.remove("33"); return context.jio.remove("33");
}) })
.then(function () { .then(function () {
store = request.result.transaction('index-store') store = request.result.transaction("index-store")
.objectStore('index-store'); .objectStore("index-store");
return new RSVP.Promise(function (resolve) { return new RSVP.Promise(function (resolve) {
records = store.getAll(); records = store.getAll();
records.onsuccess = function () { records.onsuccess = function () {
......
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