Skip to content

Commit b7a6be3

Browse files
committed
Adds tests for limit=0 and count=1.
1 parent 0797b42 commit b7a6be3

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

spec/RestQuery.spec.js

+29
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,33 @@ describe('rest query', () => {
191191
});
192192
});
193193

194+
it('query with limit = 0', (done) => {
195+
rest.create(config, nobody, 'TestObject', {foo: 'baz'}
196+
).then(() => {
197+
return rest.create(config, nobody,
198+
'TestObject', {foo: 'qux'});
199+
}).then(() => {
200+
return rest.find(config, nobody,
201+
'TestObject', {}, {limit: 0});
202+
}).then((response) => {
203+
expect(response.results.length).toEqual(0);
204+
done();
205+
});
206+
});
207+
208+
it('query with limit = 0 and count = 1', (done) => {
209+
rest.create(config, nobody, 'TestObject', {foo: 'baz'}
210+
).then(() => {
211+
return rest.create(config, nobody,
212+
'TestObject', {foo: 'qux'});
213+
}).then(() => {
214+
return rest.find(config, nobody,
215+
'TestObject', {}, {limit: 0, count: 1});
216+
}).then((response) => {
217+
expect(response.results.length).toEqual(0);
218+
expect(response.count).toEqual(2);
219+
done();
220+
});
221+
});
222+
194223
});

src/RestQuery.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ RestQuery.prototype.runFind = function() {
333333
delete result.password;
334334
}
335335
}
336-
}
337336

338337
this.config.filesController.expandFilesInObject(this.config, results);
339338

@@ -346,7 +345,6 @@ RestQuery.prototype.runFind = function() {
346345
newObject[key] = object[key];
347346
}
348347
}
349-
}
350348
return newObject;
351349
});
352350
}
@@ -355,6 +353,7 @@ RestQuery.prototype.runFind = function() {
355353
for (var r of results) {
356354
r.className = this.redirectClassName;
357355
}
356+
}
358357
this.response = {results: results};
359358
});
360359
} else {

0 commit comments

Comments
 (0)