Skip to content

Commit

Permalink
Add test for android_channel_id key in sendGCM
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-friedl committed Jun 20, 2019
1 parent 0ddbfe2 commit abd28bd
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/send/sendGCM.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,50 @@ describe('push-notifications-gcm', () => {
});
});

describe('send Android Channel ID', () => {
before(() => {
sendMethod = sinon.stub(
gcm.Sender.prototype,
'send',
(message, recipients, retries, cb) => {
expect(recipients).to.be.instanceOf(Object);
expect(recipients).to.have.property('registrationTokens');
const { registrationTokens } = recipients;
expect(registrationTokens).to.be.instanceOf(Array);
registrationTokens.forEach(regId => expect(regIds).to.include(regId));
expect(retries).to.be.a('number');
expect(message).to.be.instanceOf(gcm.Message);
expect(message.params.notification.android_channel_id).to.equal(
'channelId'
);
cb(null, {
multicast_id: 'abc',
success: registrationTokens.length,
failure: 0,
results: registrationTokens.map(token => ({
message_id: '',
registration_id: token,
error: null,
})),
});
}
);
});

after(() => {
sendMethod.restore();
});

it('all responses should be successful (callback, custom data undefined)', done => {
const channelIdData = {
android_channel_id: 'channelId',
};
pn.send(regIds, channelIdData, (err, results) =>
testSuccess(err, results, done)
);
});
});

describe('send push notifications in phonegap-push compatibility mode', () => {
const pushPhoneGap = new PN({
gcm: {
Expand Down

0 comments on commit abd28bd

Please sign in to comment.