Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nsakaimbo committed Aug 22, 2024
1 parent cf0715a commit c7c5bf2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
1 change: 0 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module.exports = {
GCM_MAX_TTL: 2419200,
// 4 weeks in seconds (https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json)
APN_METHOD: 'apn',
GCM_METHOD: 'gcm',
FCM_METHOD: 'fcm',
ADM_METHOD: 'adm',
WNS_METHOD: 'wns',
Expand Down
1 change: 0 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
DEFAULT_TTL: 28 * 86400,
GCM_MAX_TTL: 2419200, // 4 weeks in seconds (https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json)
APN_METHOD: 'apn',
GCM_METHOD: 'gcm',
FCM_METHOD: 'fcm',
ADM_METHOD: 'adm',
WNS_METHOD: 'wns',
Expand Down
28 changes: 9 additions & 19 deletions test/push-notifications/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
WEB_METHOD,
WNS_METHOD,
ADM_METHOD,
GCM_METHOD,
FCM_METHOD,
APN_METHOD,
} from '../../src/constants';
Expand All @@ -26,7 +25,6 @@ describe('push-notifications: instantiation and class properties', () => {
it('should have send methods and settings options', () => {
const pn = new PN();
expect(pn).to.have.property('send');
expect(pn.settings).to.have.property('gcm');
expect(pn.settings).to.have.property('fcm');
expect(pn.settings).to.have.property('apn');
expect(pn.settings).to.have.property('adm');
Expand All @@ -38,9 +36,6 @@ describe('push-notifications: instantiation and class properties', () => {
describe('override options with constructor', () => {
let pn;
const settings = {
gcm: {
id: 'gcm id',
},
apn: {
token: {
key: 'testKey',
Expand Down Expand Up @@ -95,10 +90,6 @@ describe('push-notifications: instantiation and class properties', () => {
describe('setOptions', () => {
let pn;
const settings = {
gcm: {
id: '123',
phonegap: false,
},
apn: {
token: {
key: 'test',
Expand All @@ -115,7 +106,6 @@ describe('push-notifications: instantiation and class properties', () => {

it('should override the options', () => {
expect(pn.settings.apn).to.eql(settings.apn);
expect(pn.settings.gcm).to.eql(settings.gcm);
expect(pn.settings).to.have.property('adm');
expect(pn.settings).to.have.property('wns');
});
Expand Down Expand Up @@ -180,11 +170,11 @@ describe('push-notifications: instantiation and class properties', () => {
},
androidObject: {
id: 'APA91bFQCD9Ndd8uVggMhj1usfeWsKIfGyBUWMprpZLGciWrMjS-77bIY24IMQNeEHzjidCcddnDxqYo-UEV03xw6ySmtIgQyzTqhSxhPGAi1maf6KDMAQGuUWc6L5Khze8YK9YrL9I_WD1gl49P3f_9hr08ZAS5Tw',
type: 'gcm',
type: 'fcm',
},
androidObjectWhatever: {
id: 'whatever',
type: 'gcm',
type: 'fcm',
},
iosObject: {
id: '43e798c31a282d129a34d84472bbdd7632562ff0732b58a85a27c5d9fdf59b69',
Expand All @@ -197,28 +187,28 @@ describe('push-notifications: instantiation and class properties', () => {
unknownRegId: 'abcdef',
};

it('Android / GCM', () => {
it('Android / FCM', () => {
let pn = new PN({ isLegacyGCM: true });
expect(pn.getPushMethodByRegId(regIds.androidRegId).regId).to.equal(
regIds.androidRegId
);
expect(pn.getPushMethodByRegId(regIds.androidRegId).pushMethod).to.equal(
GCM_METHOD
FCM_METHOD
);

expect(
pn.getPushMethodByRegId(regIds.androidWithAdmSubstringRegId).regId
).to.equal(regIds.androidWithAdmSubstringRegId);
expect(
pn.getPushMethodByRegId(regIds.androidWithAdmSubstringRegId).pushMethod
).to.equal(GCM_METHOD);
).to.equal(FCM_METHOD);

expect(
pn.getPushMethodByRegId(regIds.androidWithAmznSubscringRegId).regId
).to.equal(regIds.androidWithAmznSubscringRegId);
expect(
pn.getPushMethodByRegId(regIds.androidWithAmznSubscringRegId).pushMethod
).to.equal(GCM_METHOD);
).to.equal(FCM_METHOD);

const settings = {
isAlwaysUseFCM: true,
Expand All @@ -229,22 +219,22 @@ describe('push-notifications: instantiation and class properties', () => {
regIds.unknownRegId
);
expect(pn.getPushMethodByRegId(regIds.unknownRegId).pushMethod).to.equal(
GCM_METHOD
FCM_METHOD
);

expect(pn.getPushMethodByRegId(regIds.androidObject).regId).to.equal(
regIds.androidObject.id
);
expect(pn.getPushMethodByRegId(regIds.androidObject).pushMethod).to.equal(
GCM_METHOD
FCM_METHOD
);

expect(
pn.getPushMethodByRegId(regIds.androidObjectWhatever).regId
).to.equal(regIds.androidObjectWhatever.id);
expect(
pn.getPushMethodByRegId(regIds.androidObjectWhatever).pushMethod
).to.equal(GCM_METHOD);
).to.equal(FCM_METHOD);
});

it('Android / FCM', () => {
Expand Down

0 comments on commit c7c5bf2

Please sign in to comment.