Commit aa84a60b authored by Yaxel Perez's avatar Yaxel Perez

trying to figure out async testing

parent b5263b90
......@@ -152,7 +152,8 @@ ${JIOVERSION}: ${EXTERNALDIR}/URI.js \
${SRCDIR}/jio.storage/websqlstorage.js \
${SRCDIR}/jio.storage/fbstorage.js \
${SRCDIR}/jio.storage/cloudooostorage.js \
${SRCDIR}/jio.storage/nocapacitystorage.js
${SRCDIR}/jio.storage/nocapacitystorage.js \
${SRCDIR}/jio.storage/liststorage.js
@mkdir -p $(@D)
cat $^ > $@
......
......@@ -10402,6 +10402,10 @@ var XMLHttpRequest = global.XMLHttpRequest || module.exports,
});
};
JioProxyStorage.prototype.list = function () {
return this.__storage.list.apply(this.__storage, arguments);
};
declareMethod(JioProxyStorage, 'putAttachment', function (argument_list,
storage,
method_name) {
......
......@@ -8392,6 +8392,10 @@ return new Parser;
});
};
JioProxyStorage.prototype.list = function () {
return this.__storage.list.apply(this.__storage, arguments);
};
declareMethod(JioProxyStorage, 'putAttachment', function (argument_list,
storage,
method_name) {
......@@ -16388,3 +16392,52 @@ return new Parser;
jIO.addStorage("nocapacity", NoCapacityStorage);
}(jIO));
/*global define, jIO */
/*jslint nomen: true*/
(function (jIO) {
"use strict";
function randomId() {
// https://gist.github.com/gordonbrander/2230317
return '_' + Math.random().toString(36).substr(2, 9);
}
function ListStorage(spec) {
this._sub_storage = jIO.createJIO(spec.sub_storage);
this._signature_storage = jIO.createJIO({
"type": "indexeddb",
"database": randomId()
});
this._signature_storage.post("_", {
list: []
});
}
ListStorage.prototype.post = function () {
console.log('alright alright alright alright alright ok now ladies');
var id = this._sub_storage.post.apply(this._sub_storage, arguments),
  • @YaxelPerez all jio methods (except createJIO) are asynchronous. They all return promise.

    So, the "id" value is not at all what you expect here. It is an RSVP.Queue object.

    In this case, to get the real id, you must do something like:

    return this._sub_storage.post.apply(this._sub_storage, arguments)
      .push(function (id) {
        console.log('The real id ' + id);
      });
Please register or sign in to reply
updated_list = this._signature_storage.get("_").list.concat(id);
this._signature_storage.put("_", {list: updated_list});
};
ListStorage.prototype.get = function () {
return this._sub_storage.get.apply(this._sub_storage, arguments);
};
ListStorage.prototype.put = function () {
return this._sub_storage.put.apply(this._sub_storage, arguments);
};
ListStorage.prototype.remove = function (id) {
var updated_list = this._signature_storage.get("_")
.list.filter(function (x) { return x !== id; });
this._signature_storage.put("_", { list: updated_list });
};
ListStorage.prototype.list = function () {
return this._sub_storage.get("_").list;
};
jIO.addStorage("list", ListStorage);
}(jIO));
......@@ -10402,6 +10402,10 @@ var XMLHttpRequest = global.XMLHttpRequest || module.exports,
});
};
JioProxyStorage.prototype.list = function () {
return this.__storage.list.apply(this.__storage, arguments);
};
declareMethod(JioProxyStorage, 'putAttachment', function (argument_list,
storage,
method_name) {
......
......@@ -8392,6 +8392,10 @@ return new Parser;
});
};
JioProxyStorage.prototype.list = function () {
return this.__storage.list.apply(this.__storage, arguments);
};
declareMethod(JioProxyStorage, 'putAttachment', function (argument_list,
storage,
method_name) {
......@@ -16388,3 +16392,52 @@ return new Parser;
jIO.addStorage("nocapacity", NoCapacityStorage);
}(jIO));
/*global define, jIO */
/*jslint nomen: true*/
(function (jIO) {
"use strict";
function randomId() {
// https://gist.github.com/gordonbrander/2230317
return '_' + Math.random().toString(36).substr(2, 9);
}
function ListStorage(spec) {
this._sub_storage = jIO.createJIO(spec.sub_storage);
this._signature_storage = jIO.createJIO({
"type": "indexeddb",
"database": randomId()
});
this._signature_storage.post("_", {
list: []
});
}
ListStorage.prototype.post = function () {
console.log('alright alright alright alright alright ok now ladies');
var id = this._sub_storage.post.apply(this._sub_storage, arguments),
updated_list = this._signature_storage.get("_").list.concat(id);
this._signature_storage.put("_", {list: updated_list});
};
ListStorage.prototype.get = function () {
return this._sub_storage.get.apply(this._sub_storage, arguments);
};
ListStorage.prototype.put = function () {
return this._sub_storage.put.apply(this._sub_storage, arguments);
};
ListStorage.prototype.remove = function (id) {
var updated_list = this._signature_storage.get("_")
.list.filter(function (x) { return x !== id; });
this._signature_storage.put("_", { list: updated_list });
};
ListStorage.prototype.list = function () {
return this._sub_storage.get("_").list;
};
jIO.addStorage("list", ListStorage);
}(jIO));
......@@ -330,6 +330,10 @@
});
};
JioProxyStorage.prototype.list = function () {
return this.__storage.list.apply(this.__storage, arguments);
};
declareMethod(JioProxyStorage, 'putAttachment', function (argument_list,
storage,
method_name) {
......
......@@ -38,6 +38,10 @@ See https://www.nexedi.com/licensing for rationale and options.
<script src="jio/tests.js"></script-->
<script src="jio/util.js"></script>
<!-- temporarily putting my stuff on top for convenience TODO: fix -->
<script src="jio.storage/nocapacitystorage.tests.js"></script>
<script src="jio.storage/liststorage.tests.js"></script>
<script src="queries/key.tests.js"></script>
<script src="queries/key-schema.tests.js"></script>
<script src="queries/tests.js"></script>
......@@ -47,7 +51,6 @@ See https://www.nexedi.com/licensing for rationale and options.
<script src="queries/key-jiodate.tests.js"></script>
<!--script src="queries/key-localstorage.tests.js"></script-->
<script src="jio.storage/nocapacitystorage.tests.js"></script>
<script src="jio.storage/memorystorage.tests.js"></script>
<script src="jio.storage/querystorage.tests.js"></script>
......
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