Skip to content

Commit 75db3b3

Browse files
committed
Add pagination test and paging
1 parent 0a3e334 commit 75db3b3

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

ClearBlade.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ if (!window.console) {
309309
};
310310

311311
var addToQuery = function(queryObj, key, value) {
312-
queryObj.query.key = value;
312+
queryObj.query[key] = value;
313313
};
314314

315315
var addFilterToQuery = function (queryObj, condition, key, value) {
@@ -846,14 +846,6 @@ if (!window.console) {
846846
return this;
847847
};
848848

849-
/**
850-
* TODO: ???
851-
*/
852-
ClearBlade.Query.prototype.setLimit = function (limit) {
853-
this.limit = limit;
854-
return this;
855-
};
856-
857849
/**
858850
* TODO: Write docs
859851
*/

test/ClearBladeSpec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,37 @@ describe("ClearBlade Query fetching with anonymous user", function() {
337337
expect(returnedData[0].name).toEqual('aaron');
338338
});
339339
});
340+
341+
it("should allow pagination options", function() {
342+
var flag, returnedData, isAaronCreated;
343+
runs(function () {
344+
var query = new ClearBlade.Query();
345+
query.equalTo('name', 'aaron');
346+
col.remove(query,function() {
347+
col.create({
348+
name: "aaron",
349+
age: 25
350+
}, function(err, response) {
351+
expect(err).toEqual(false);
352+
isAaronCreated = true;
353+
});
354+
});
355+
});
356+
357+
waitsFor(function() {
358+
return isAaronCreated;
359+
}, "aaron should be created", TEST_TIMEOUT);
360+
361+
var queryDone, queryDone2;
362+
// Negative case -- should return nothing
363+
runs(function() {
364+
var query = new ClearBlade.Query();
365+
query.equalTo('name', 'aaron');
366+
query.setPage(10, 1);
367+
expect(query.query.PAGESIZE).toEqual(10);
368+
expect(query.query.PAGENUM).toEqual(1);
369+
});
370+
});
340371
});
341372

342373
describe("ClearBlade collections fetching", function () {

0 commit comments

Comments
 (0)