Commit 4c66f034 authored by Yaxel Perez's avatar Yaxel Perez

forgot remove method

parent 66c28293
......@@ -59,10 +59,17 @@
});
};
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.remove = function () {
var ctx = this;
return this._sub_storage.remove.apply(this._sub_storage, arguments)
.then(function (id) {
return ctx.list().then(function (list) {
list = list.filter(function (x) { return id !== x; });
return ctx._signature_storage.put('_', list).then(function () {
return id;
});
});
});
};
jIO.addStorage("list", ListStorage);
......
......@@ -64,5 +64,31 @@
}).fail(console.error);
});
QUnit.test('remove method correctly removes id', function (assert) {
QUnit.stop();
QUnit.expect(1);
var jio = jIO.createJIO({
type: 'list',
sub_storage: {
type: 'uuid',
sub_storage: {
type: 'memory'
}
}
});
jio.put('test', {}).then(function () {
jio.put('test2', {}).then(function () {
jio.remove('test').then(function () {
jio.list().then(function (l2) {
QUnit.start();
assert.deepEqual(l2, ['test2']);
});
});
});
}).fail(console.error);
});
// }(jIO, RSVP, QUnit));
}(jIO, QUnit));
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