Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
1,037 changes: 397 additions & 640 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"license": "MIT",
"dependencies": {
"@parse/node-apn": "6.5.0",
"@parse/node-gcm": "1.0.2",
"expo-server-sdk": "3.15.0",
"firebase-admin": "13.5.0",
"npmlog": "7.0.1",
Expand Down
39 changes: 20 additions & 19 deletions spec/FCM.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { deleteApp, getApps } from 'firebase-admin/app';
import { expectAsync } from '@jasmine/core';
import log from 'npmlog';
import Parse from 'parse/node.js';
import path from 'path';
Expand Down Expand Up @@ -27,8 +28,8 @@ describe('FCM', () => {
});

it('can throw on initializing with invalid args', () => {
expect(function() { new FCM(123); }).toThrow();
expect(function() { new FCM({}); }).toThrow();
expect(function () { new FCM(123); }).toThrow();
expect(function () { new FCM({}); }).toThrow();
});

it('does log on invalid payload', async () => {
Expand Down Expand Up @@ -71,8 +72,8 @@ describe('FCM', () => {
});

it('can send successful FCM android request', async () => {
const spyVerbose = spyOn(log, 'verbose').and.callFake(() => {});
const spyInfo = spyOn(log, 'info').and.callFake(() => {});
const spyVerbose = spyOn(log, 'verbose').and.callFake(() => { });
const spyInfo = spyOn(log, 'info').and.callFake(() => { });
const fcm = new FCM(testArgs);
spyOn(fcm.sender, 'sendEachForMulticast').and.callFake(() => {
return Promise.resolve({
Expand All @@ -98,8 +99,8 @@ describe('FCM', () => {
});

it('can send successful FCM android request with apns integer keys', async () => {
const spyVerbose = spyOn(log, 'verbose').and.callFake(() => {});
const spyInfo = spyOn(log, 'info').and.callFake(() => {});
const spyVerbose = spyOn(log, 'verbose').and.callFake(() => { });
const spyInfo = spyOn(log, 'info').and.callFake(() => { });
const fcm = new FCM(testArgs);
spyOn(fcm.sender, 'sendEachForMulticast').and.callFake(() => {
return Promise.resolve({
Expand All @@ -126,8 +127,8 @@ describe('FCM', () => {
});

it('can send successful FCM apple request with alert', async () => {
const spyVerbose = spyOn(log, 'verbose').and.callFake(() => {});
const spyInfo = spyOn(log, 'info').and.callFake(() => {});
const spyVerbose = spyOn(log, 'verbose').and.callFake(() => { });
const spyInfo = spyOn(log, 'info').and.callFake(() => { });
const fcm = new FCM(testArgs);
spyOn(fcm.sender, 'sendEachForMulticast').and.callFake(() => {
return Promise.resolve({
Expand All @@ -153,8 +154,8 @@ describe('FCM', () => {
});

it('can send successful FCM apple request with title', async () => {
const spyVerbose = spyOn(log, 'verbose').and.callFake(() => {});
const spyInfo = spyOn(log, 'info').and.callFake(() => {});
const spyVerbose = spyOn(log, 'verbose').and.callFake(() => { });
const spyInfo = spyOn(log, 'info').and.callFake(() => { });
const fcm = new FCM(testArgs);
spyOn(fcm.sender, 'sendEachForMulticast').and.callFake(() => {
return Promise.resolve({
Expand All @@ -180,8 +181,8 @@ describe('FCM', () => {
});

it('can send failed FCM request', async () => {
const spyInfo = spyOn(log, 'info').and.callFake(() => {});
const spyError = spyOn(log, 'error').and.callFake(() => {});
const spyInfo = spyOn(log, 'info').and.callFake(() => { });
const spyError = spyOn(log, 'error').and.callFake(() => { });
const fcm = new FCM(testArgs);
spyOn(fcm.sender, 'sendEachForMulticast').and.callFake(() => {
return Promise.resolve({
Expand All @@ -203,14 +204,14 @@ describe('FCM', () => {
expect(spyError.calls.all()[1].args).toEqual(['parse-server-push-adapter FCM', 'tokens with failed pushes: ["token"]']);
expect(response).toEqual([[{
device: { deviceToken: 'token', deviceType: 'apple' },
response: { error: 'testing failed'},
response: { error: 'testing failed' },
transmitted: false,
}]]);
});

it('can handle FCM request error', async () => {
const spyInfo = spyOn(log, 'info').and.callFake(() => {});
const spyError = spyOn(log, 'error').and.callFake(() => {});
const spyInfo = spyOn(log, 'info').and.callFake(() => { });
const spyError = spyOn(log, 'error').and.callFake(() => { });
const fcm = new FCM(testArgs);
spyOn(fcm.sender, 'sendEachForMulticast').and.callFake(() => {
return Promise.reject('testing error abort');
Expand All @@ -225,8 +226,8 @@ describe('FCM', () => {
});

it('rejects exceptions that are unhandled by FCM client', async () => {
const spyInfo = spyOn(log, 'info').and.callFake(() => {});
const spyError = spyOn(log, 'error').and.callFake(() => {});
const spyInfo = spyOn(log, 'info').and.callFake(() => { });
const spyError = spyOn(log, 'error').and.callFake(() => { });
testArgs.resolveUnhandledClientError = false;
const fcm = new FCM(testArgs);
spyOn(fcm.sender, 'sendEachForMulticast').and.callFake(() => {
Expand All @@ -244,8 +245,8 @@ describe('FCM', () => {
});

it('resolves exceptions that are unhandled by FCM client', async () => {
const spyInfo = spyOn(log, 'info').and.callFake(() => {});
const spyError = spyOn(log, 'error').and.callFake(() => {});
const spyInfo = spyOn(log, 'info').and.callFake(() => { });
const spyError = spyOn(log, 'error').and.callFake(() => { });
testArgs.resolveUnhandledClientError = true;
const fcm = new FCM(testArgs);
spyOn(fcm.sender, 'sendEachForMulticast').and.callFake(() => {
Expand Down
Loading
Loading