Skip to content

Commit

Permalink
StoreAdapter: Add test and proposed fix for totalLength promise
Browse files Browse the repository at this point in the history
  • Loading branch information
kfranqueiro authored and kriszyp committed Mar 19, 2015
1 parent a98fb32 commit 9cc63ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion legacy/StoreAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ define([
if (results) {
// apply the object restoration
return new QueryResults(results.map(this._restore, this), {
totalLength: results.total
totalLength: when(results.total)
});
}
return results;
Expand Down
7 changes: 7 additions & 0 deletions tests/legacy/StoreAdapter-Memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ define([
assert.strictEqual(results[1].describe(), 'four is not a prime');
},

fetch: function () {
var totalLength = store.fetch().totalLength;
assert.isDefined(totalLength, 'totalLength should be defined on fetch results');
assert.strictEqual(typeof totalLength.then, 'function',
'totalLength should be a promise');
},

'filter': function () {
assert.strictEqual(getResultsArray(store.filter({prime: true})).length, 3);
assert.strictEqual(getResultsArray(store.filter({even: true}))[1].name, 'four');
Expand Down

0 comments on commit 9cc63ae

Please sign in to comment.