Commit cbfbeb77 authored by yogevbd's avatar yogevbd

Fix lint

parent 942d62fa
import {NativeModules, DeviceEventEmitter} from "react-native"; import {NativeModules, DeviceEventEmitter} from 'react-native';
import NotificationAndroid from "./notification"; import NotificationAndroid from './notification';
const RNNotifications = NativeModules.WixRNNotifications; const RNNotifications = NativeModules.WixRNNotifications;
...@@ -10,7 +10,7 @@ let registrationTokenUpdateListener; ...@@ -10,7 +10,7 @@ let registrationTokenUpdateListener;
export class NotificationsAndroid { export class NotificationsAndroid {
static setNotificationOpenedListener(listener) { static setNotificationOpenedListener(listener) {
notificationOpenedListener = DeviceEventEmitter.addListener("notificationOpened", (notification) => listener(new NotificationAndroid(notification))); notificationOpenedListener = DeviceEventEmitter.addListener('notificationOpened', (notification) => listener(new NotificationAndroid(notification)));
} }
static clearNotificationOpenedListener() { static clearNotificationOpenedListener() {
...@@ -21,11 +21,11 @@ export class NotificationsAndroid { ...@@ -21,11 +21,11 @@ export class NotificationsAndroid {
} }
static setNotificationReceivedListener(listener) { static setNotificationReceivedListener(listener) {
notificationReceivedListener = DeviceEventEmitter.addListener("notificationReceived", (notification) => listener(new NotificationAndroid(notification))); notificationReceivedListener = DeviceEventEmitter.addListener('notificationReceived', (notification) => listener(new NotificationAndroid(notification)));
} }
static setNotificationReceivedInForegroundListener(listener) { static setNotificationReceivedInForegroundListener(listener) {
notificationReceivedInForegroundListener = DeviceEventEmitter.addListener("notificationReceivedInForeground", (notification) => listener(new NotificationAndroid(notification))); notificationReceivedInForegroundListener = DeviceEventEmitter.addListener('notificationReceivedInForeground', (notification) => listener(new NotificationAndroid(notification)));
} }
static clearNotificationReceivedListener() { static clearNotificationReceivedListener() {
...@@ -43,7 +43,7 @@ export class NotificationsAndroid { ...@@ -43,7 +43,7 @@ export class NotificationsAndroid {
} }
static setRegistrationTokenUpdateListener(listener) { static setRegistrationTokenUpdateListener(listener) {
registrationTokenUpdateListener = DeviceEventEmitter.addListener("remoteNotificationsRegistered", listener); registrationTokenUpdateListener = DeviceEventEmitter.addListener('remoteNotificationsRegistered', listener);
} }
static clearRegistrationTokenUpdateListener() { static clearRegistrationTokenUpdateListener() {
......
/** /**
* @flow * @flow
*/ */
"use strict"; 'use strict';
import { NativeModules, DeviceEventEmitter, NativeAppEventEmitter } from "react-native"; import { NativeModules, DeviceEventEmitter, NativeAppEventEmitter } from 'react-native';
import Map from "core-js/library/es6/map"; import Map from 'core-js/library/es6/map';
import uuid from "uuid"; import uuid from 'uuid';
const NativeRNNotifications = NativeModules.RNBridgeModule; // eslint-disable-line no-unused-vars const NativeRNNotifications = NativeModules.RNBridgeModule; // eslint-disable-line no-unused-vars
import IOSNotification from "./notification.ios"; import IOSNotification from './notification.ios';
export const DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT = "remoteNotificationsRegistered"; export const DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT = 'remoteNotificationsRegistered';
export const DEVICE_REMOTE_NOTIFICATIONS_REGISTRATION_FAILED_EVENT = "remoteNotificationsRegistrationFailed"; export const DEVICE_REMOTE_NOTIFICATIONS_REGISTRATION_FAILED_EVENT = 'remoteNotificationsRegistrationFailed';
export const DEVICE_PUSH_KIT_REGISTERED_EVENT = "pushKitRegistered"; export const DEVICE_PUSH_KIT_REGISTERED_EVENT = 'pushKitRegistered';
export const DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT = "notificationReceivedForeground"; export const DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT = 'notificationReceivedForeground';
export const DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT = "notificationReceivedBackground"; export const DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT = 'notificationReceivedBackground';
export const DEVICE_NOTIFICATION_OPENED_EVENT = "notificationOpened"; export const DEVICE_NOTIFICATION_OPENED_EVENT = 'notificationOpened';
const DEVICE_NOTIFICATION_ACTION_RECEIVED = "notificationActionReceived"; const DEVICE_NOTIFICATION_ACTION_RECEIVED = 'notificationActionReceived';
const _exportedEvents = [ const _exportedEvents = [
DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT, DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT,
...@@ -200,7 +200,7 @@ export default class NotificationsIOS { ...@@ -200,7 +200,7 @@ export default class NotificationsIOS {
* *
* - `alertBody` : The message displayed in the notification alert. * - `alertBody` : The message displayed in the notification alert.
* - `alertTitle` : The message title displayed in the notification. * - `alertTitle` : The message title displayed in the notification.
* - `alertAction` : The "action" displayed beneath an actionable notification. Defaults to "view"; * - `alertAction` : The 'action' displayed beneath an actionable notification. Defaults to 'view';
* - `soundName` : The sound played when the notification is fired (optional). * - `soundName` : The sound played when the notification is fired (optional).
* - `silent` : If true, the notification sound will be suppressed (optional). * - `silent` : If true, the notification sound will be suppressed (optional).
* - `category` : The category of this notification, required for actionable notifications (optional). * - `category` : The category of this notification, required for actionable notifications (optional).
......
...@@ -11,8 +11,8 @@ export default class IOSNotification { ...@@ -11,8 +11,8 @@ export default class IOSNotification {
this._data = {}; this._data = {};
if (notification.aps && if (notification.aps &&
notification.aps["content-available"] && notification.aps['content-available'] &&
notification.aps["content-available"] === 1 && notification.aps['content-available'] === 1 &&
!notification.aps.alert && !notification.aps.alert &&
!notification.aps.sound && !notification.aps.sound &&
notification.managedAps) { notification.managedAps) {
...@@ -21,8 +21,8 @@ export default class IOSNotification { ...@@ -21,8 +21,8 @@ export default class IOSNotification {
this._sound = notification.managedAps.sound; this._sound = notification.managedAps.sound;
this._badge = notification.aps.badge; this._badge = notification.aps.badge;
this._category = notification.managedAps.category; this._category = notification.managedAps.category;
this._type = "managed"; this._type = 'managed';
this._thread = notification.aps["thread-id"]; this._thread = notification.aps['thread-id'];
} else if ( } else if (
notification.aps && notification.aps &&
notification.aps.alert) { notification.aps.alert) {
...@@ -31,11 +31,11 @@ export default class IOSNotification { ...@@ -31,11 +31,11 @@ export default class IOSNotification {
this._sound = notification.aps.sound; this._sound = notification.aps.sound;
this._badge = notification.aps.badge; this._badge = notification.aps.badge;
this._category = notification.aps.category; this._category = notification.aps.category;
this._type = "regular"; this._type = 'regular';
this._thread = notification.aps["thread-id"]; this._thread = notification.aps['thread-id'];
} }
Object.keys(notification).filter(key => key !== "aps").forEach(key => { Object.keys(notification).filter(key => key !== 'aps').forEach(key => {
this._data[key] = notification[key]; this._data[key] = notification[key];
}); });
} }
......
This diff is collapsed.
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"babel-register": "^6.7.2", "babel-register": "^6.7.2",
"chai": "^3.5.0", "chai": "^3.5.0",
"chokidar-cli": "^1.2.0", "chokidar-cli": "^1.2.0",
"eslint": "5.1.x", "eslint": "6.0.1",
"mocha": "^2.5.3", "mocha": "^2.5.3",
"proxyquire": "^1.7.4", "proxyquire": "^1.7.4",
"sinon": "^1.17.3", "sinon": "^1.17.3",
......
"use strict"; 'use strict';
let expect = require("chai").use(require("sinon-chai")).expect; let expect = require('chai').use(require('sinon-chai')).expect;
import proxyquire from "proxyquire"; import proxyquire from 'proxyquire';
import sinon from "sinon"; import sinon from 'sinon';
describe("Notifications-Android > ", () => { describe('Notifications-Android > ', () => {
proxyquire.noCallThru(); proxyquire.noCallThru();
let refreshTokenStub; let refreshTokenStub;
...@@ -19,8 +19,8 @@ describe("Notifications-Android > ", () => { ...@@ -19,8 +19,8 @@ describe("Notifications-Android > ", () => {
cancelLocalNotificationStub = sinon.stub(); cancelLocalNotificationStub = sinon.stub();
deviceEventEmitterListenerStub = sinon.stub(); deviceEventEmitterListenerStub = sinon.stub();
libUnderTest = proxyquire("../index.android", { libUnderTest = proxyquire('../index.android', {
"react-native": { 'react-native': {
NativeModules: { NativeModules: {
WixRNNotifications: { WixRNNotifications: {
refreshToken: refreshTokenStub, refreshToken: refreshTokenStub,
...@@ -33,22 +33,22 @@ describe("Notifications-Android > ", () => { ...@@ -33,22 +33,22 @@ describe("Notifications-Android > ", () => {
addListener: deviceEventEmitterListenerStub addListener: deviceEventEmitterListenerStub
} }
}, },
"./notification": require("../notification.android") './notification': require('../notification.android')
}); });
}); });
describe("Registration token API", () => { describe('Registration token API', () => {
it("should assign callback to native event upon listener registration", () => { it('should assign callback to native event upon listener registration', () => {
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
const userListener = () => {}; const userListener = () => {};
libUnderTest.NotificationsAndroid.setRegistrationTokenUpdateListener(userListener); libUnderTest.NotificationsAndroid.setRegistrationTokenUpdateListener(userListener);
expect(deviceEventEmitterListenerStub).to.have.been.calledWith("remoteNotificationsRegistered", userListener); expect(deviceEventEmitterListenerStub).to.have.been.calledWith('remoteNotificationsRegistered', userListener);
expect(deviceEventEmitterListenerStub).to.have.been.calledOnce; expect(deviceEventEmitterListenerStub).to.have.been.calledOnce;
}); });
it("should clear native event listener upon listener deregister", () => { it('should clear native event listener upon listener deregister', () => {
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
const userListener = () => {}; const userListener = () => {};
const nativeListener = { const nativeListener = {
...@@ -62,28 +62,28 @@ describe("Notifications-Android > ", () => { ...@@ -62,28 +62,28 @@ describe("Notifications-Android > ", () => {
expect(nativeListener.remove).to.have.been.calledOnce; expect(nativeListener.remove).to.have.been.calledOnce;
}); });
it("shouldn't fail if deregister without registering", () => { it('shouldn`t fail if deregister without registering', () => {
libUnderTest.NotificationsAndroid.clearRegistrationTokenUpdateListener(); libUnderTest.NotificationsAndroid.clearRegistrationTokenUpdateListener();
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
}); });
}); });
describe("notification-opening API", () => { describe('notification-opening API', () => {
it("should assign callback to native event upon registration", () => { it('should assign callback to native event upon registration', () => {
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
const userListenerStub = sinon.stub(); const userListenerStub = sinon.stub();
libUnderTest.NotificationsAndroid.setNotificationOpenedListener(userListenerStub); libUnderTest.NotificationsAndroid.setNotificationOpenedListener(userListenerStub);
expect(deviceEventEmitterListenerStub).to.have.been.calledOnce; expect(deviceEventEmitterListenerStub).to.have.been.calledOnce;
expect(deviceEventEmitterListenerStub).to.have.been.calledWith("notificationOpened", sinon.match.func); expect(deviceEventEmitterListenerStub).to.have.been.calledWith('notificationOpened', sinon.match.func);
}); });
it("should assign a wrapper-callback upon registration", () => { it('should assign a wrapper-callback upon registration', () => {
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
const userListenerStub = sinon.stub(); const userListenerStub = sinon.stub();
const notification = { foo: "bar" }; const notification = { foo: 'bar' };
libUnderTest.NotificationsAndroid.setNotificationOpenedListener(userListenerStub); libUnderTest.NotificationsAndroid.setNotificationOpenedListener(userListenerStub);
...@@ -93,7 +93,7 @@ describe("Notifications-Android > ", () => { ...@@ -93,7 +93,7 @@ describe("Notifications-Android > ", () => {
expect(userListenerStub.args[0][0].getData()).to.equal(notification); expect(userListenerStub.args[0][0].getData()).to.equal(notification);
}); });
it("should clear native event listener upon listener deregister", () => { it('should clear native event listener upon listener deregister', () => {
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
const userListener = () => {}; const userListener = () => {};
const nativeListener = { const nativeListener = {
...@@ -107,28 +107,28 @@ describe("Notifications-Android > ", () => { ...@@ -107,28 +107,28 @@ describe("Notifications-Android > ", () => {
expect(nativeListener.remove).to.have.been.calledOnce; expect(nativeListener.remove).to.have.been.calledOnce;
}); });
it("shouldn't fail if deregister without registering", () => { it('shouldnt fail if deregister without registering', () => {
libUnderTest.NotificationsAndroid.clearNotificationOpenedListener(); libUnderTest.NotificationsAndroid.clearNotificationOpenedListener();
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
}); });
}); });
describe("notification-receive API", () => { describe('notification-receive API', () => {
it("should assign callback to native event upon registration", () => { it('should assign callback to native event upon registration', () => {
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
const userListenerStub = sinon.stub(); const userListenerStub = sinon.stub();
libUnderTest.NotificationsAndroid.setNotificationReceivedListener(userListenerStub); libUnderTest.NotificationsAndroid.setNotificationReceivedListener(userListenerStub);
expect(deviceEventEmitterListenerStub).to.have.been.calledOnce; expect(deviceEventEmitterListenerStub).to.have.been.calledOnce;
expect(deviceEventEmitterListenerStub).to.have.been.calledWith("notificationReceived", sinon.match.func); expect(deviceEventEmitterListenerStub).to.have.been.calledWith('notificationReceived', sinon.match.func);
}); });
it("should assign a wrapper-callback upon registration", () => { it('should assign a wrapper-callback upon registration', () => {
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
const userListenerStub = sinon.stub(); const userListenerStub = sinon.stub();
const notification = { foo: "bar" }; const notification = { foo: 'bar' };
libUnderTest.NotificationsAndroid.setNotificationReceivedListener(userListenerStub); libUnderTest.NotificationsAndroid.setNotificationReceivedListener(userListenerStub);
...@@ -138,7 +138,7 @@ describe("Notifications-Android > ", () => { ...@@ -138,7 +138,7 @@ describe("Notifications-Android > ", () => {
expect(userListenerStub.args[0][0].getData()).to.equal(notification); expect(userListenerStub.args[0][0].getData()).to.equal(notification);
}); });
it("should clear native event listener upon listener deregister", () => { it('should clear native event listener upon listener deregister', () => {
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
const userListener = () => {}; const userListener = () => {};
const nativeListener = { const nativeListener = {
...@@ -152,25 +152,25 @@ describe("Notifications-Android > ", () => { ...@@ -152,25 +152,25 @@ describe("Notifications-Android > ", () => {
expect(nativeListener.remove).to.have.been.calledOnce; expect(nativeListener.remove).to.have.been.calledOnce;
}); });
it("shouldn't fail if deregister without registering", () => { it('shouldn`t fail if deregister without registering', () => {
libUnderTest.NotificationsAndroid.clearNotificationReceivedListener(); libUnderTest.NotificationsAndroid.clearNotificationReceivedListener();
expect(deviceEventEmitterListenerStub).to.not.have.been.called; expect(deviceEventEmitterListenerStub).to.not.have.been.called;
}); });
}); });
describe("Notification token", () => { describe('Notification token', () => {
it("should refresh notification token upon refreshing request by the user", () => { it('should refresh notification token upon refreshing request by the user', () => {
expect(refreshTokenStub).to.not.have.been.called; expect(refreshTokenStub).to.not.have.been.called;
libUnderTest.NotificationsAndroid.refreshToken(); libUnderTest.NotificationsAndroid.refreshToken();
expect(refreshTokenStub).to.have.been.calledOnce; expect(refreshTokenStub).to.have.been.calledOnce;
}); });
}); });
describe("Initial notification API", () => { describe('Initial notification API', () => {
it("should return initial notification data if available", (done) => { it('should return initial notification data if available', (done) => {
expect(getInitialNotificationStub).to.not.have.been.called; expect(getInitialNotificationStub).to.not.have.been.called;
const rawNotification = {foo: "bar"}; const rawNotification = {foo: 'bar'};
getInitialNotificationStub.returns(Promise.resolve(rawNotification)); getInitialNotificationStub.returns(Promise.resolve(rawNotification));
libUnderTest.PendingNotifications.getInitialNotification() libUnderTest.PendingNotifications.getInitialNotification()
...@@ -181,7 +181,7 @@ describe("Notifications-Android > ", () => { ...@@ -181,7 +181,7 @@ describe("Notifications-Android > ", () => {
.catch((err) => done(err)); .catch((err) => done(err));
}); });
it("should return empty notification if not available", (done) => { it('should return empty notification if not available', (done) => {
expect(getInitialNotificationStub).to.not.have.been.called; expect(getInitialNotificationStub).to.not.have.been.called;
getInitialNotificationStub.returns(Promise.resolve(null)); getInitialNotificationStub.returns(Promise.resolve(null));
...@@ -195,13 +195,13 @@ describe("Notifications-Android > ", () => { ...@@ -195,13 +195,13 @@ describe("Notifications-Android > ", () => {
}); });
describe("Local notification", () => { describe('Local notification', () => {
const notification = { const notification = {
title: "notification-title", title: 'notification-title',
body: "notification-body" body: 'notification-body'
}; };
it("should get published when posted manually", () => { it('should get published when posted manually', () => {
expect(postLocalNotificationStub).to.not.have.been.called; expect(postLocalNotificationStub).to.not.have.been.called;
const id = libUnderTest.NotificationsAndroid.localNotification(notification); const id = libUnderTest.NotificationsAndroid.localNotification(notification);
...@@ -209,7 +209,7 @@ describe("Notifications-Android > ", () => { ...@@ -209,7 +209,7 @@ describe("Notifications-Android > ", () => {
expect(postLocalNotificationStub).to.have.been.calledWith(notification, id); expect(postLocalNotificationStub).to.have.been.calledWith(notification, id);
}); });
it("should be called with a unique ID", () => { it('should be called with a unique ID', () => {
expect(postLocalNotificationStub).to.not.have.been.called; expect(postLocalNotificationStub).to.not.have.been.called;
const id = libUnderTest.NotificationsAndroid.localNotification(notification); const id = libUnderTest.NotificationsAndroid.localNotification(notification);
...@@ -219,7 +219,7 @@ describe("Notifications-Android > ", () => { ...@@ -219,7 +219,7 @@ describe("Notifications-Android > ", () => {
expect(id).to.not.equal(id2); expect(id).to.not.equal(id2);
}); });
it("should be cancellable with an ID", () => { it('should be cancellable with an ID', () => {
expect(cancelLocalNotificationStub).to.not.have.been.called; expect(cancelLocalNotificationStub).to.not.have.been.called;
libUnderTest.NotificationsAndroid.cancelLocalNotification(666); libUnderTest.NotificationsAndroid.cancelLocalNotification(666);
...@@ -227,5 +227,4 @@ describe("Notifications-Android > ", () => { ...@@ -227,5 +227,4 @@ describe("Notifications-Android > ", () => {
expect(cancelLocalNotificationStub).to.have.been.calledWith(666); expect(cancelLocalNotificationStub).to.have.been.calledWith(666);
}); });
}); });
}); });
This diff is collapsed.
"use strict"; 'use strict';
import { expect } from "chai"; import { expect } from 'chai';
import IOSNotification from "../notification.ios"; import IOSNotification from '../notification.ios';
describe("iOS Notification Object", () => { describe('iOS Notification Object', () => {
let notification; let notification;
let someBadgeCount = 123, someSound = "someSound", someCategory = "some_notification_category", someThread = "thread-1"; let someBadgeCount = 123, someSound = 'someSound', someCategory = 'some_notification_category', someThread = 'thread-1';
describe("for a regular iOS push notification", () => { describe('for a regular iOS push notification', () => {
let regularNativeNotifications = [ let regularNativeNotifications = [
// basic example, without content-available = 1 (aka silent notification) // basic example, without content-available = 1 (aka silent notification)
{ {
aps: { aps: {
alert: { alert: {
title: "some title", title: 'some title',
body: "some body" body: 'some body'
}, },
badge: someBadgeCount, badge: someBadgeCount,
sound: someSound, sound: someSound,
category: someCategory, category: someCategory,
"thread-id": someThread 'thread-id': someThread
}, },
key1: "value1", key1: 'value1',
key2: "value2" key2: 'value2'
}, },
// another example, with content-available but also with alert object (should not be a silent notification) // another example, with content-available but also with alert object (should not be a silent notification)
{ {
aps: { aps: {
"content-available": 1, 'content-available': 1,
alert: { alert: {
title: "some title", title: 'some title',
body: "some body" body: 'some body'
}, },
badge: someBadgeCount, badge: someBadgeCount,
sound: someSound, sound: someSound,
category: someCategory, category: someCategory,
"thread-id": someThread 'thread-id': someThread
}, },
key1: "value1", key1: 'value1',
key2: "value2" key2: 'value2'
} }
]; ];
...@@ -47,82 +47,82 @@ describe("iOS Notification Object", () => { ...@@ -47,82 +47,82 @@ describe("iOS Notification Object", () => {
notification = new IOSNotification(nativeNotification); notification = new IOSNotification(nativeNotification);
}); });
it("should return 'regular' type", function () { it('should return regular type', function () {
expect(notification.getType()).to.equal("regular"); expect(notification.getType()).to.equal('regular');
}); });
it("should return the alert object", () => { it('should return the alert object', () => {
expect(notification.getMessage()).to.deep.equal(nativeNotification.aps.alert); expect(notification.getMessage()).to.deep.equal(nativeNotification.aps.alert);
}); });
it("should return the sound", () => { it('should return the sound', () => {
expect(notification.getSound()).to.equal(someSound); expect(notification.getSound()).to.equal(someSound);
}); });
it("should return the badge count", () => { it('should return the badge count', () => {
expect(notification.getBadgeCount()).to.equal(someBadgeCount); expect(notification.getBadgeCount()).to.equal(someBadgeCount);
}); });
it("should return the category", () => { it('should return the category', () => {
expect(notification.getCategory()).to.equal(someCategory); expect(notification.getCategory()).to.equal(someCategory);
}); });
it("should return the thread", () => { it('should return the thread', () => {
expect(notification.getThread()).to.equal("thread-1"); expect(notification.getThread()).to.equal('thread-1');
}); });
it("should return the custom data", () => { it('should return the custom data', () => {
expect(notification.getData()).to.deep.equal({ key1: "value1", key2: "value2" }); expect(notification.getData()).to.deep.equal({ key1: 'value1', key2: 'value2' });
}); });
}); });
}); });
describe("for a managed iOS push notification (silent notification, with managedAps key and content-available = 1)", () => { describe('for a managed iOS push notification (silent notification, with managedAps key and content-available = 1)', () => {
let managedNativeNotification = { let managedNativeNotification = {
aps: { aps: {
"content-available": 1, 'content-available': 1,
badge: someBadgeCount badge: someBadgeCount
}, },
managedAps: { managedAps: {
action: "CREATE", action: 'CREATE',
notificationId: "1", notificationId: '1',
alert: { alert: {
title: "some title", title: 'some title',
body: "some body" body: 'some body'
}, },
sound: someSound, sound: someSound,
category: someCategory category: someCategory
}, },
key1: "value1", key1: 'value1',
key2: "value2" key2: 'value2'
}; };
beforeEach(() => { beforeEach(() => {
notification = new IOSNotification(managedNativeNotification); notification = new IOSNotification(managedNativeNotification);
}); });
it("should return 'managed' type", function () { it('should return managed type', function () {
expect(notification.getType()).to.equal("managed"); expect(notification.getType()).to.equal('managed');
}); });
it("should return the alert object", () => { it('should return the alert object', () => {
expect(notification.getMessage()).to.equal(managedNativeNotification.managedAps.alert); expect(notification.getMessage()).to.equal(managedNativeNotification.managedAps.alert);
}); });
it("should return the sound", () => { it('should return the sound', () => {
expect(notification.getSound()).to.equal(someSound); expect(notification.getSound()).to.equal(someSound);
}); });
it("should return the badge count", () => { it('should return the badge count', () => {
expect(notification.getBadgeCount()).to.equal(someBadgeCount); expect(notification.getBadgeCount()).to.equal(someBadgeCount);
}); });
it("should return the category", () => { it('should return the category', () => {
expect(notification.getCategory()).to.equal(someCategory); expect(notification.getCategory()).to.equal(someCategory);
}); });
it("should return the custom data", () => { it('should return the custom data', () => {
expect(notification.getData()).to.deep.equal({ managedAps: managedNativeNotification.managedAps, key1: "value1", key2: "value2" }); expect(notification.getData()).to.deep.equal({ managedAps: managedNativeNotification.managedAps, key1: 'value1', key2: 'value2' });
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment