Skip to content

Verify pushes are sent to the expected number of installations #3418

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

Merged
merged 2 commits into from
Jan 28, 2017
Merged
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
25 changes: 20 additions & 5 deletions spec/Parse.Push.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ const delayPromise = (delay) => {

describe('Parse.Push', () => {
var setup = function() {
var sendToInstallationSpy = jasmine.createSpy();

var pushAdapter = {
send: function(body, installations) {
var badge = body.data.badge;
const promises = installations.map((installation) => {
sendToInstallationSpy(installation);

if (installation.deviceType == "ios") {
expect(installation.badge).toEqual(badge);
expect(installation.originalBadge + 1).toEqual(installation.badge);
Expand Down Expand Up @@ -53,13 +57,21 @@ describe('Parse.Push', () => {
installations.push(installation);
}
return Parse.Object.saveAll(installations);
}).catch((err) => {
})
.then(() => {
return {
sendToInstallationSpy,
};
})
.catch((err) => {
console.error(err);

throw err;
})
}

it('should properly send push', (done) => {
return setup().then(() => {
return setup().then(({ sendToInstallationSpy }) => {
return Parse.Push.send({
where: {
deviceType: 'ios'
Expand All @@ -69,10 +81,13 @@ describe('Parse.Push', () => {
alert: 'Hello world!'
}
}, {useMasterKey: true})
.then(() => {
return delayPromise(500);
})
.then(() => {
expect(sendToInstallationSpy.calls.count()).toEqual(10);
})
}).then(() => {
return delayPromise(500);
})
.then(() => {
done();
}).catch((err) => {
jfail(err);
Expand Down