Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server info proper values #3933

Merged
merged 4 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,102 @@ describe('server', () => {
})
});

it('can properly sets the push support', done => {
// default config passes push options
const config = new Config('test');
expect(config.hasPushSupport).toEqual(true);
expect(config.hasPushScheduledSupport).toEqual(false);
request.get({
url: 'http://localhost:8378/1/serverInfo',
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
},
json: true,
}, (error, response, body) => {
expect(body.features.push.immediatePush).toEqual(true);
expect(body.features.push.scheduledPush).toEqual(false);
done();
})
});

it('can properly sets the push support when not configured', done => {
reconfigureServer({
push: undefined // force no config
}).then(() => {
const config = new Config('test');
expect(config.hasPushSupport).toEqual(false);
expect(config.hasPushScheduledSupport).toEqual(false);
request.get({
url: 'http://localhost:8378/1/serverInfo',
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
},
json: true,
}, (error, response, body) => {
expect(body.features.push.immediatePush).toEqual(false);
expect(body.features.push.scheduledPush).toEqual(false);
done();
})
}).catch(done.fail);
});

it('can properly sets the push support ', done => {
reconfigureServer({
push: {
adapter: {
send() {},
getValidPushTypes() {}
}
}
}).then(() => {
const config = new Config('test');
expect(config.hasPushSupport).toEqual(true);
expect(config.hasPushScheduledSupport).toEqual(false);
request.get({
url: 'http://localhost:8378/1/serverInfo',
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
},
json: true,
}, (error, response, body) => {
expect(body.features.push.immediatePush).toEqual(true);
expect(body.features.push.scheduledPush).toEqual(false);
done();
})
}).catch(done.fail);
});

it('can properly sets the push schedule support', done => {
reconfigureServer({
push: {
adapter: {
send() {},
getValidPushTypes() {}
}
},
scheduledPush: true,
}).then(() => {
const config = new Config('test');
expect(config.hasPushSupport).toEqual(true);
expect(config.hasPushScheduledSupport).toEqual(true);
request.get({
url: 'http://localhost:8378/1/serverInfo',
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
},
json: true,
}, (error, response, body) => {
expect(body.features.push.immediatePush).toEqual(true);
expect(body.features.push.scheduledPush).toEqual(true);
done();
})
}).catch(done.fail);
});

it('can respond 200 on path health', done => {
request.get({
url: 'http://localhost:8378/1/health',
Expand Down
5 changes: 2 additions & 3 deletions src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ class ParseServer {
// We pass the options and the base class for the adatper,
// Note that passing an instance would work too
const pushController = new PushController();

const hasPushSupport = pushAdapter && push;
const hasPushScheduledSupport = pushAdapter && push && scheduledPush;
const hasPushSupport = !!(pushAdapter && push);
const hasPushScheduledSupport = hasPushSupport && (scheduledPush === true);

const {
disablePushWorker
Expand Down