Permalink
Browse files

Fix for issue #57.

  • Loading branch information...
1 parent 4ef3b28 commit 6c44634f1a75f59e6a40bff404ff9aaed799d1a7 Niall Smart committed Sep 23, 2011
Showing with 7 additions and 4 deletions.
  1. +2 −2 src/adapters/dom.js
  2. +5 −2 test/lawnchair-spec.js
View
@@ -104,15 +104,15 @@ Lawnchair.adapter('dom', (function() {
var k = this.name + '.' + key[i]
, obj = JSON.parse(storage.getItem(k))
if (obj) {
- obj.key = k
+ obj.key = key[i]
r.push(obj)
}
}
if (callback) this.lambda(callback).call(this, r)
} else {
var k = this.name + '.' + key
, obj = JSON.parse(storage.getItem(k))
- if (obj) obj.key = k
+ if (obj) obj.key = key
if (callback) this.lambda(callback).call(this, obj)
}
return this
View
@@ -270,11 +270,12 @@ test( 'should it be chainable?', function() {
});
test('get functionality', function() {
- QUnit.expect(3);
+ QUnit.expect(4);
QUnit.stop();
store.save({key:'xyz', name:'tim'}, function() {
store.get('xyz', function(r) {
+ equals(r.key, 'xyz', 'should return key in loaded object');
equals(r.name, 'tim', 'should return proper object when calling get with a key');
store.get('doesntexist', function(s) {
ok(true, 'should call callback even for non-existent key');
@@ -286,12 +287,14 @@ test('get functionality', function() {
});
test('get batch functionality', function() {
- QUnit.expect(1);
+ QUnit.expect(3);
QUnit.stop(500);
var t = [{key:'test-get'},{key:'test-get-1'}]
store.batch(t, function() {
this.get(['test-get','test-get-1'], function(r) {
+ equals(r[0].key, 'test-get', "get first object");
+ equals(r[1].key, 'test-get-1', "get second object");
equals(r.length, t.length, "should batch get")
QUnit.start()
})

0 comments on commit 6c44634

Please sign in to comment.