Skip to content

Commit d67be49

Browse files
ricmatsuiArthur Cinader
authored and
Arthur Cinader
committed
Verify pushes are sent to the expected number of installations (#3418)
1 parent ea45f69 commit d67be49

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

spec/Parse.Push.spec.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ const delayPromise = (delay) => {
1010

1111
describe('Parse.Push', () => {
1212
var setup = function() {
13+
var sendToInstallationSpy = jasmine.createSpy();
14+
1315
var pushAdapter = {
1416
send: function(body, installations) {
1517
var badge = body.data.badge;
1618
const promises = installations.map((installation) => {
19+
sendToInstallationSpy(installation);
20+
1721
if (installation.deviceType == "ios") {
1822
expect(installation.badge).toEqual(badge);
1923
expect(installation.originalBadge + 1).toEqual(installation.badge);
@@ -53,13 +57,21 @@ describe('Parse.Push', () => {
5357
installations.push(installation);
5458
}
5559
return Parse.Object.saveAll(installations);
56-
}).catch((err) => {
60+
})
61+
.then(() => {
62+
return {
63+
sendToInstallationSpy,
64+
};
65+
})
66+
.catch((err) => {
5767
console.error(err);
68+
69+
throw err;
5870
})
5971
}
6072

6173
it('should properly send push', (done) => {
62-
return setup().then(() => {
74+
return setup().then(({ sendToInstallationSpy }) => {
6375
return Parse.Push.send({
6476
where: {
6577
deviceType: 'ios'
@@ -69,10 +81,13 @@ describe('Parse.Push', () => {
6981
alert: 'Hello world!'
7082
}
7183
}, {useMasterKey: true})
84+
.then(() => {
85+
return delayPromise(500);
86+
})
87+
.then(() => {
88+
expect(sendToInstallationSpy.calls.count()).toEqual(10);
89+
})
7290
}).then(() => {
73-
return delayPromise(500);
74-
})
75-
.then(() => {
7691
done();
7792
}).catch((err) => {
7893
jfail(err);

0 commit comments

Comments
 (0)