Skip to content

Commit 9d79ba1

Browse files
authored
Server info proper values (#3933)
* Adds failing test * Makes sure booleans are proper booleans * nits * Double negate so it also takes care of null
1 parent 92fa6f2 commit 9d79ba1

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed

spec/index.spec.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,102 @@ describe('server', () => {
164164
})
165165
});
166166

167+
it('can properly sets the push support', done => {
168+
// default config passes push options
169+
const config = new Config('test');
170+
expect(config.hasPushSupport).toEqual(true);
171+
expect(config.hasPushScheduledSupport).toEqual(false);
172+
request.get({
173+
url: 'http://localhost:8378/1/serverInfo',
174+
headers: {
175+
'X-Parse-Application-Id': 'test',
176+
'X-Parse-Master-Key': 'test',
177+
},
178+
json: true,
179+
}, (error, response, body) => {
180+
expect(body.features.push.immediatePush).toEqual(true);
181+
expect(body.features.push.scheduledPush).toEqual(false);
182+
done();
183+
})
184+
});
185+
186+
it('can properly sets the push support when not configured', done => {
187+
reconfigureServer({
188+
push: undefined // force no config
189+
}).then(() => {
190+
const config = new Config('test');
191+
expect(config.hasPushSupport).toEqual(false);
192+
expect(config.hasPushScheduledSupport).toEqual(false);
193+
request.get({
194+
url: 'http://localhost:8378/1/serverInfo',
195+
headers: {
196+
'X-Parse-Application-Id': 'test',
197+
'X-Parse-Master-Key': 'test',
198+
},
199+
json: true,
200+
}, (error, response, body) => {
201+
expect(body.features.push.immediatePush).toEqual(false);
202+
expect(body.features.push.scheduledPush).toEqual(false);
203+
done();
204+
})
205+
}).catch(done.fail);
206+
});
207+
208+
it('can properly sets the push support ', done => {
209+
reconfigureServer({
210+
push: {
211+
adapter: {
212+
send() {},
213+
getValidPushTypes() {}
214+
}
215+
}
216+
}).then(() => {
217+
const config = new Config('test');
218+
expect(config.hasPushSupport).toEqual(true);
219+
expect(config.hasPushScheduledSupport).toEqual(false);
220+
request.get({
221+
url: 'http://localhost:8378/1/serverInfo',
222+
headers: {
223+
'X-Parse-Application-Id': 'test',
224+
'X-Parse-Master-Key': 'test',
225+
},
226+
json: true,
227+
}, (error, response, body) => {
228+
expect(body.features.push.immediatePush).toEqual(true);
229+
expect(body.features.push.scheduledPush).toEqual(false);
230+
done();
231+
})
232+
}).catch(done.fail);
233+
});
234+
235+
it('can properly sets the push schedule support', done => {
236+
reconfigureServer({
237+
push: {
238+
adapter: {
239+
send() {},
240+
getValidPushTypes() {}
241+
}
242+
},
243+
scheduledPush: true,
244+
}).then(() => {
245+
const config = new Config('test');
246+
expect(config.hasPushSupport).toEqual(true);
247+
expect(config.hasPushScheduledSupport).toEqual(true);
248+
request.get({
249+
url: 'http://localhost:8378/1/serverInfo',
250+
headers: {
251+
'X-Parse-Application-Id': 'test',
252+
'X-Parse-Master-Key': 'test',
253+
},
254+
json: true,
255+
}, (error, response, body) => {
256+
expect(body.features.push.immediatePush).toEqual(true);
257+
expect(body.features.push.scheduledPush).toEqual(true);
258+
done();
259+
})
260+
}).catch(done.fail);
261+
});
262+
167263
it('can respond 200 on path health', done => {
168264
request.get({
169265
url: 'http://localhost:8378/1/health',

src/ParseServer.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ class ParseServer {
181181
// We pass the options and the base class for the adatper,
182182
// Note that passing an instance would work too
183183
const pushController = new PushController();
184-
185-
const hasPushSupport = pushAdapter && push;
186-
const hasPushScheduledSupport = pushAdapter && push && scheduledPush;
184+
const hasPushSupport = !!(pushAdapter && push);
185+
const hasPushScheduledSupport = hasPushSupport && (scheduledPush === true);
187186

188187
const {
189188
disablePushWorker

0 commit comments

Comments
 (0)