* Add condition at limit = 0 * Add tests for installations with limit and count parameters
This commit is contained in:
@@ -71,4 +71,100 @@ describe('InstallationsRouter', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('query installations with limit = 0', (done) => {
|
||||||
|
var androidDeviceRequest = {
|
||||||
|
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
|
||||||
|
'deviceType': 'android'
|
||||||
|
};
|
||||||
|
var iosDeviceRequest = {
|
||||||
|
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
|
||||||
|
'deviceType': 'ios'
|
||||||
|
};
|
||||||
|
var request = {
|
||||||
|
config: config,
|
||||||
|
auth: auth.master(config),
|
||||||
|
body: {},
|
||||||
|
query: {
|
||||||
|
limit: 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var router = new InstallationsRouter();
|
||||||
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
||||||
|
.then(() => {
|
||||||
|
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
|
||||||
|
}).then(() => {
|
||||||
|
return router.handleFind(request);
|
||||||
|
}).then((res) => {
|
||||||
|
var response = res.response;
|
||||||
|
expect(response.results.length).toEqual(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('query installations with count = 1', (done) => {
|
||||||
|
var androidDeviceRequest = {
|
||||||
|
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
|
||||||
|
'deviceType': 'android'
|
||||||
|
};
|
||||||
|
var iosDeviceRequest = {
|
||||||
|
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
|
||||||
|
'deviceType': 'ios'
|
||||||
|
};
|
||||||
|
var request = {
|
||||||
|
config: config,
|
||||||
|
auth: auth.master(config),
|
||||||
|
body: {},
|
||||||
|
query: {
|
||||||
|
count: 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var router = new InstallationsRouter();
|
||||||
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
||||||
|
.then(() => {
|
||||||
|
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
|
||||||
|
}).then(() => {
|
||||||
|
return router.handleFind(request);
|
||||||
|
}).then((res) => {
|
||||||
|
var response = res.response;
|
||||||
|
expect(response.results.length).toEqual(2);
|
||||||
|
expect(response.count).toEqual(2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('query installations with limit = 0 and count = 1', (done) => {
|
||||||
|
var androidDeviceRequest = {
|
||||||
|
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
|
||||||
|
'deviceType': 'android'
|
||||||
|
};
|
||||||
|
var iosDeviceRequest = {
|
||||||
|
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
|
||||||
|
'deviceType': 'ios'
|
||||||
|
};
|
||||||
|
var request = {
|
||||||
|
config: config,
|
||||||
|
auth: auth.master(config),
|
||||||
|
body: {},
|
||||||
|
query: {
|
||||||
|
limit: 0,
|
||||||
|
count: 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var router = new InstallationsRouter();
|
||||||
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
||||||
|
.then(() => {
|
||||||
|
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
|
||||||
|
}).then(() => {
|
||||||
|
return router.handleFind(request);
|
||||||
|
}).then((res) => {
|
||||||
|
var response = res.response;
|
||||||
|
expect(response.results.length).toEqual(0);
|
||||||
|
expect(response.count).toEqual(2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class InstallationsRouter extends ClassesRouter {
|
|||||||
if (body.skip) {
|
if (body.skip) {
|
||||||
options.skip = Number(body.skip);
|
options.skip = Number(body.skip);
|
||||||
}
|
}
|
||||||
if (body.limit) {
|
if (body.limit || body.limit === 0) {
|
||||||
options.limit = Number(body.limit);
|
options.limit = Number(body.limit);
|
||||||
}
|
}
|
||||||
if (body.order) {
|
if (body.order) {
|
||||||
|
|||||||
Reference in New Issue
Block a user