Skip to content

Commit 6cfcb4d

Browse files
ssk7833drew-gross
authored andcommitted
Fix #1755 (#1756)
* Add condition at limit = 0 * Add tests for installations with limit and count parameters
1 parent 10ee229 commit 6cfcb4d

File tree

2 files changed

+97
-1
lines changed

2 files changed

+97
-1
lines changed

spec/InstallationsRouter.spec.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,100 @@ describe('InstallationsRouter', () => {
7171
done();
7272
});
7373
});
74+
75+
it('query installations with limit = 0', (done) => {
76+
var androidDeviceRequest = {
77+
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
78+
'deviceType': 'android'
79+
};
80+
var iosDeviceRequest = {
81+
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
82+
'deviceType': 'ios'
83+
};
84+
var request = {
85+
config: config,
86+
auth: auth.master(config),
87+
body: {},
88+
query: {
89+
limit: 0
90+
}
91+
};
92+
93+
var router = new InstallationsRouter();
94+
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
95+
.then(() => {
96+
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
97+
}).then(() => {
98+
return router.handleFind(request);
99+
}).then((res) => {
100+
var response = res.response;
101+
expect(response.results.length).toEqual(0);
102+
done();
103+
});
104+
});
105+
106+
it('query installations with count = 1', (done) => {
107+
var androidDeviceRequest = {
108+
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
109+
'deviceType': 'android'
110+
};
111+
var iosDeviceRequest = {
112+
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
113+
'deviceType': 'ios'
114+
};
115+
var request = {
116+
config: config,
117+
auth: auth.master(config),
118+
body: {},
119+
query: {
120+
count: 1
121+
}
122+
};
123+
124+
var router = new InstallationsRouter();
125+
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
126+
.then(() => {
127+
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
128+
}).then(() => {
129+
return router.handleFind(request);
130+
}).then((res) => {
131+
var response = res.response;
132+
expect(response.results.length).toEqual(2);
133+
expect(response.count).toEqual(2);
134+
done();
135+
});
136+
});
137+
138+
it('query installations with limit = 0 and count = 1', (done) => {
139+
var androidDeviceRequest = {
140+
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
141+
'deviceType': 'android'
142+
};
143+
var iosDeviceRequest = {
144+
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
145+
'deviceType': 'ios'
146+
};
147+
var request = {
148+
config: config,
149+
auth: auth.master(config),
150+
body: {},
151+
query: {
152+
limit: 0,
153+
count: 1
154+
}
155+
};
156+
157+
var router = new InstallationsRouter();
158+
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
159+
.then(() => {
160+
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
161+
}).then(() => {
162+
return router.handleFind(request);
163+
}).then((res) => {
164+
var response = res.response;
165+
expect(response.results.length).toEqual(0);
166+
expect(response.count).toEqual(2);
167+
done();
168+
});
169+
});
74170
});

src/Routers/InstallationsRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class InstallationsRouter extends ClassesRouter {
1212
if (body.skip) {
1313
options.skip = Number(body.skip);
1414
}
15-
if (body.limit) {
15+
if (body.limit || body.limit === 0) {
1616
options.limit = Number(body.limit);
1717
}
1818
if (body.order) {

0 commit comments

Comments
 (0)