Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-notifications
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
冷佳娟
react-native-notifications
Commits
cbfbeb77
Commit
cbfbeb77
authored
Jul 04, 2019
by
yogevbd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lint
parent
942d62fa
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
378 additions
and
382 deletions
+378
-382
index.android.js
index.android.js
+6
-6
index.ios.js
index.ios.js
+13
-13
notification.ios.js
notification.ios.js
+7
-7
package-lock.json
package-lock.json
+197
-200
package.json
package.json
+1
-1
test/index.android.spec.js
test/index.android.spec.js
+39
-40
test/index.ios.spec.js
test/index.ios.spec.js
+72
-72
test/notification.ios.spec.js
test/notification.ios.spec.js
+43
-43
No files found.
index.android.js
View file @
cbfbeb77
import
{
NativeModules
,
DeviceEventEmitter
}
from
"
react-native
"
;
import
NotificationAndroid
from
"
./notification
"
;
import
{
NativeModules
,
DeviceEventEmitter
}
from
'
react-native
'
;
import
NotificationAndroid
from
'
./notification
'
;
const
RNNotifications
=
NativeModules
.
WixRNNotifications
;
...
...
@@ -10,7 +10,7 @@ let registrationTokenUpdateListener;
export
class
NotificationsAndroid
{
static
setNotificationOpenedListener
(
listener
)
{
notificationOpenedListener
=
DeviceEventEmitter
.
addListener
(
"
notificationOpened
"
,
(
notification
)
=>
listener
(
new
NotificationAndroid
(
notification
)));
notificationOpenedListener
=
DeviceEventEmitter
.
addListener
(
'
notificationOpened
'
,
(
notification
)
=>
listener
(
new
NotificationAndroid
(
notification
)));
}
static
clearNotificationOpenedListener
()
{
...
...
@@ -21,11 +21,11 @@ export class NotificationsAndroid {
}
static
setNotificationReceivedListener
(
listener
)
{
notificationReceivedListener
=
DeviceEventEmitter
.
addListener
(
"
notificationReceived
"
,
(
notification
)
=>
listener
(
new
NotificationAndroid
(
notification
)));
notificationReceivedListener
=
DeviceEventEmitter
.
addListener
(
'
notificationReceived
'
,
(
notification
)
=>
listener
(
new
NotificationAndroid
(
notification
)));
}
static
setNotificationReceivedInForegroundListener
(
listener
)
{
notificationReceivedInForegroundListener
=
DeviceEventEmitter
.
addListener
(
"
notificationReceivedInForeground
"
,
(
notification
)
=>
listener
(
new
NotificationAndroid
(
notification
)));
notificationReceivedInForegroundListener
=
DeviceEventEmitter
.
addListener
(
'
notificationReceivedInForeground
'
,
(
notification
)
=>
listener
(
new
NotificationAndroid
(
notification
)));
}
static
clearNotificationReceivedListener
()
{
...
...
@@ -43,7 +43,7 @@ export class NotificationsAndroid {
}
static
setRegistrationTokenUpdateListener
(
listener
)
{
registrationTokenUpdateListener
=
DeviceEventEmitter
.
addListener
(
"
remoteNotificationsRegistered
"
,
listener
);
registrationTokenUpdateListener
=
DeviceEventEmitter
.
addListener
(
'
remoteNotificationsRegistered
'
,
listener
);
}
static
clearRegistrationTokenUpdateListener
()
{
...
...
index.ios.js
View file @
cbfbeb77
/**
* @flow
*/
"
use strict
"
;
import
{
NativeModules
,
DeviceEventEmitter
,
NativeAppEventEmitter
}
from
"
react-native
"
;
import
Map
from
"
core-js/library/es6/map
"
;
import
uuid
from
"
uuid
"
;
'
use strict
'
;
import
{
NativeModules
,
DeviceEventEmitter
,
NativeAppEventEmitter
}
from
'
react-native
'
;
import
Map
from
'
core-js/library/es6/map
'
;
import
uuid
from
'
uuid
'
;
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_REGISTRATION_FAILED_EVENT
=
"
remoteNotificationsRegistrationFailed
"
;
export
const
DEVICE_PUSH_KIT_REGISTERED_EVENT
=
"
pushKitRegistered
"
;
export
const
DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT
=
"
notificationReceivedForeground
"
;
export
const
DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT
=
"
notificationReceivedBackground
"
;
export
const
DEVICE_NOTIFICATION_OPENED_EVENT
=
"
notificationOpened
"
;
export
const
DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT
=
'
remoteNotificationsRegistered
'
;
export
const
DEVICE_REMOTE_NOTIFICATIONS_REGISTRATION_FAILED_EVENT
=
'
remoteNotificationsRegistrationFailed
'
;
export
const
DEVICE_PUSH_KIT_REGISTERED_EVENT
=
'
pushKitRegistered
'
;
export
const
DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT
=
'
notificationReceivedForeground
'
;
export
const
DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT
=
'
notificationReceivedBackground
'
;
export
const
DEVICE_NOTIFICATION_OPENED_EVENT
=
'
notificationOpened
'
;
const
DEVICE_NOTIFICATION_ACTION_RECEIVED
=
"
notificationActionReceived
"
;
const
DEVICE_NOTIFICATION_ACTION_RECEIVED
=
'
notificationActionReceived
'
;
const
_exportedEvents
=
[
DEVICE_REMOTE_NOTIFICATIONS_REGISTERED_EVENT
,
...
...
@@ -200,7 +200,7 @@ export default class NotificationsIOS {
*
* - `alertBody` : The message displayed in the notification alert.
* - `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).
* - `silent` : If true, the notification sound will be suppressed (optional).
* - `category` : The category of this notification, required for actionable notifications (optional).
...
...
notification.ios.js
View file @
cbfbeb77
...
...
@@ -11,8 +11,8 @@ export default class IOSNotification {
this
.
_data
=
{};
if
(
notification
.
aps
&&
notification
.
aps
[
"
content-available
"
]
&&
notification
.
aps
[
"
content-available
"
]
===
1
&&
notification
.
aps
[
'
content-available
'
]
&&
notification
.
aps
[
'
content-available
'
]
===
1
&&
!
notification
.
aps
.
alert
&&
!
notification
.
aps
.
sound
&&
notification
.
managedAps
)
{
...
...
@@ -21,8 +21,8 @@ export default class IOSNotification {
this
.
_sound
=
notification
.
managedAps
.
sound
;
this
.
_badge
=
notification
.
aps
.
badge
;
this
.
_category
=
notification
.
managedAps
.
category
;
this
.
_type
=
"
managed
"
;
this
.
_thread
=
notification
.
aps
[
"
thread-id
"
];
this
.
_type
=
'
managed
'
;
this
.
_thread
=
notification
.
aps
[
'
thread-id
'
];
}
else
if
(
notification
.
aps
&&
notification
.
aps
.
alert
)
{
...
...
@@ -31,11 +31,11 @@ export default class IOSNotification {
this
.
_sound
=
notification
.
aps
.
sound
;
this
.
_badge
=
notification
.
aps
.
badge
;
this
.
_category
=
notification
.
aps
.
category
;
this
.
_type
=
"
regular
"
;
this
.
_thread
=
notification
.
aps
[
"
thread-id
"
];
this
.
_type
=
'
regular
'
;
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
];
});
}
...
...
package-lock.json
View file @
cbfbeb77
This diff is collapsed.
Click to expand it.
package.json
View file @
cbfbeb77
...
...
@@ -39,7 +39,7 @@
"
babel-register
"
:
"
^6.7.2
"
,
"
chai
"
:
"
^3.5.0
"
,
"
chokidar-cli
"
:
"
^1.2.0
"
,
"
eslint
"
:
"
5.1.x
"
,
"
eslint
"
:
"
6.0.1
"
,
"
mocha
"
:
"
^2.5.3
"
,
"
proxyquire
"
:
"
^1.7.4
"
,
"
sinon
"
:
"
^1.17.3
"
,
...
...
test/index.android.spec.js
View file @
cbfbeb77
"
use strict
"
;
let
expect
=
require
(
"
chai
"
).
use
(
require
(
"
sinon-chai
"
)).
expect
;
import
proxyquire
from
"
proxyquire
"
;
import
sinon
from
"
sinon
"
;
'
use strict
'
;
let
expect
=
require
(
'
chai
'
).
use
(
require
(
'
sinon-chai
'
)).
expect
;
import
proxyquire
from
'
proxyquire
'
;
import
sinon
from
'
sinon
'
;
describe
(
"
Notifications-Android >
"
,
()
=>
{
describe
(
'
Notifications-Android >
'
,
()
=>
{
proxyquire
.
noCallThru
();
let
refreshTokenStub
;
...
...
@@ -19,8 +19,8 @@ describe("Notifications-Android > ", () => {
cancelLocalNotificationStub
=
sinon
.
stub
();
deviceEventEmitterListenerStub
=
sinon
.
stub
();
libUnderTest
=
proxyquire
(
"
../index.android
"
,
{
"
react-native
"
:
{
libUnderTest
=
proxyquire
(
'
../index.android
'
,
{
'
react-native
'
:
{
NativeModules
:
{
WixRNNotifications
:
{
refreshToken
:
refreshTokenStub
,
...
...
@@ -33,22 +33,22 @@ describe("Notifications-Android > ", () => {
addListener
:
deviceEventEmitterListenerStub
}
},
"
./notification
"
:
require
(
"
../notification.android
"
)
'
./notification
'
:
require
(
'
../notification.android
'
)
});
});
describe
(
"
Registration token API
"
,
()
=>
{
it
(
"
should assign callback to native event upon listener registration
"
,
()
=>
{
describe
(
'
Registration token API
'
,
()
=>
{
it
(
'
should assign callback to native event upon listener registration
'
,
()
=>
{
expect
(
deviceEventEmitterListenerStub
).
to
.
not
.
have
.
been
.
called
;
const
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
;
});
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
;
const
userListener
=
()
=>
{};
const
nativeListener
=
{
...
...
@@ -62,28 +62,28 @@ describe("Notifications-Android > ", () => {
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
();
expect
(
deviceEventEmitterListenerStub
).
to
.
not
.
have
.
been
.
called
;
});
});
describe
(
"
notification-opening API
"
,
()
=>
{
it
(
"
should assign callback to native event upon registration
"
,
()
=>
{
describe
(
'
notification-opening API
'
,
()
=>
{
it
(
'
should assign callback to native event upon registration
'
,
()
=>
{
expect
(
deviceEventEmitterListenerStub
).
to
.
not
.
have
.
been
.
called
;
const
userListenerStub
=
sinon
.
stub
();
libUnderTest
.
NotificationsAndroid
.
setNotificationOpenedListener
(
userListenerStub
);
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
;
const
userListenerStub
=
sinon
.
stub
();
const
notification
=
{
foo
:
"
bar
"
};
const
notification
=
{
foo
:
'
bar
'
};
libUnderTest
.
NotificationsAndroid
.
setNotificationOpenedListener
(
userListenerStub
);
...
...
@@ -93,7 +93,7 @@ describe("Notifications-Android > ", () => {
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
;
const
userListener
=
()
=>
{};
const
nativeListener
=
{
...
...
@@ -107,28 +107,28 @@ describe("Notifications-Android > ", () => {
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
();
expect
(
deviceEventEmitterListenerStub
).
to
.
not
.
have
.
been
.
called
;
});
});
describe
(
"
notification-receive API
"
,
()
=>
{
it
(
"
should assign callback to native event upon registration
"
,
()
=>
{
describe
(
'
notification-receive API
'
,
()
=>
{
it
(
'
should assign callback to native event upon registration
'
,
()
=>
{
expect
(
deviceEventEmitterListenerStub
).
to
.
not
.
have
.
been
.
called
;
const
userListenerStub
=
sinon
.
stub
();
libUnderTest
.
NotificationsAndroid
.
setNotificationReceivedListener
(
userListenerStub
);
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
;
const
userListenerStub
=
sinon
.
stub
();
const
notification
=
{
foo
:
"
bar
"
};
const
notification
=
{
foo
:
'
bar
'
};
libUnderTest
.
NotificationsAndroid
.
setNotificationReceivedListener
(
userListenerStub
);
...
...
@@ -138,7 +138,7 @@ describe("Notifications-Android > ", () => {
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
;
const
userListener
=
()
=>
{};
const
nativeListener
=
{
...
...
@@ -152,25 +152,25 @@ describe("Notifications-Android > ", () => {
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
();
expect
(
deviceEventEmitterListenerStub
).
to
.
not
.
have
.
been
.
called
;
});
});
describe
(
"
Notification token
"
,
()
=>
{
it
(
"
should refresh notification token upon refreshing request by the user
"
,
()
=>
{
describe
(
'
Notification token
'
,
()
=>
{
it
(
'
should refresh notification token upon refreshing request by the user
'
,
()
=>
{
expect
(
refreshTokenStub
).
to
.
not
.
have
.
been
.
called
;
libUnderTest
.
NotificationsAndroid
.
refreshToken
();
expect
(
refreshTokenStub
).
to
.
have
.
been
.
calledOnce
;
});
});
describe
(
"
Initial notification API
"
,
()
=>
{
it
(
"
should return initial notification data if available
"
,
(
done
)
=>
{
describe
(
'
Initial notification API
'
,
()
=>
{
it
(
'
should return initial notification data if available
'
,
(
done
)
=>
{
expect
(
getInitialNotificationStub
).
to
.
not
.
have
.
been
.
called
;
const
rawNotification
=
{
foo
:
"
bar
"
};
const
rawNotification
=
{
foo
:
'
bar
'
};
getInitialNotificationStub
.
returns
(
Promise
.
resolve
(
rawNotification
));
libUnderTest
.
PendingNotifications
.
getInitialNotification
()
...
...
@@ -181,7 +181,7 @@ describe("Notifications-Android > ", () => {
.
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
;
getInitialNotificationStub
.
returns
(
Promise
.
resolve
(
null
));
...
...
@@ -195,13 +195,13 @@ describe("Notifications-Android > ", () => {
});
describe
(
"
Local notification
"
,
()
=>
{
describe
(
'
Local notification
'
,
()
=>
{
const
notification
=
{
title
:
"
notification-title
"
,
body
:
"
notification-body
"
title
:
'
notification-title
'
,
body
:
'
notification-body
'
};
it
(
"
should get published when posted manually
"
,
()
=>
{
it
(
'
should get published when posted manually
'
,
()
=>
{
expect
(
postLocalNotificationStub
).
to
.
not
.
have
.
been
.
called
;
const
id
=
libUnderTest
.
NotificationsAndroid
.
localNotification
(
notification
);
...
...
@@ -209,7 +209,7 @@ describe("Notifications-Android > ", () => {
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
;
const
id
=
libUnderTest
.
NotificationsAndroid
.
localNotification
(
notification
);
...
...
@@ -219,7 +219,7 @@ describe("Notifications-Android > ", () => {
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
;
libUnderTest
.
NotificationsAndroid
.
cancelLocalNotification
(
666
);
...
...
@@ -227,5 +227,4 @@ describe("Notifications-Android > ", () => {
expect
(
cancelLocalNotificationStub
).
to
.
have
.
been
.
calledWith
(
666
);
});
});
});
test/index.ios.spec.js
View file @
cbfbeb77
This diff is collapsed.
Click to expand it.
test/notification.ios.spec.js
View file @
cbfbeb77
"
use strict
"
;
import
{
expect
}
from
"
chai
"
;
import
IOSNotification
from
"
../notification.ios
"
;
'
use strict
'
;
import
{
expect
}
from
'
chai
'
;
import
IOSNotification
from
'
../notification.ios
'
;
describe
(
"
iOS Notification Object
"
,
()
=>
{
describe
(
'
iOS Notification Object
'
,
()
=>
{
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
=
[
// basic example, without content-available = 1 (aka silent notification)
{
aps
:
{
alert
:
{
title
:
"
some title
"
,
body
:
"
some body
"
title
:
'
some title
'
,
body
:
'
some body
'
},
badge
:
someBadgeCount
,
sound
:
someSound
,
category
:
someCategory
,
"
thread-id
"
:
someThread
'
thread-id
'
:
someThread
},
key1
:
"
value1
"
,
key2
:
"
value2
"
key1
:
'
value1
'
,
key2
:
'
value2
'
},
// another example, with content-available but also with alert object (should not be a silent notification)
{
aps
:
{
"
content-available
"
:
1
,
'
content-available
'
:
1
,
alert
:
{
title
:
"
some title
"
,
body
:
"
some body
"
title
:
'
some title
'
,
body
:
'
some body
'
},
badge
:
someBadgeCount
,
sound
:
someSound
,
category
:
someCategory
,
"
thread-id
"
:
someThread
'
thread-id
'
:
someThread
},
key1
:
"
value1
"
,
key2
:
"
value2
"
key1
:
'
value1
'
,
key2
:
'
value2
'
}
];
...
...
@@ -47,82 +47,82 @@ describe("iOS Notification Object", () => {
notification
=
new
IOSNotification
(
nativeNotification
);
});
it
(
"
should return 'regular' type
"
,
function
()
{
expect
(
notification
.
getType
()).
to
.
equal
(
"
regular
"
);
it
(
'
should return regular type
'
,
function
()
{
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
);
});
it
(
"
should return the sound
"
,
()
=>
{
it
(
'
should return the sound
'
,
()
=>
{
expect
(
notification
.
getSound
()).
to
.
equal
(
someSound
);
});
it
(
"
should return the badge count
"
,
()
=>
{
it
(
'
should return the badge count
'
,
()
=>
{
expect
(
notification
.
getBadgeCount
()).
to
.
equal
(
someBadgeCount
);
});
it
(
"
should return the category
"
,
()
=>
{
it
(
'
should return the category
'
,
()
=>
{
expect
(
notification
.
getCategory
()).
to
.
equal
(
someCategory
);
});
it
(
"
should return the thread
"
,
()
=>
{
expect
(
notification
.
getThread
()).
to
.
equal
(
"
thread-1
"
);
it
(
'
should return the thread
'
,
()
=>
{
expect
(
notification
.
getThread
()).
to
.
equal
(
'
thread-1
'
);
});
it
(
"
should return the custom data
"
,
()
=>
{
expect
(
notification
.
getData
()).
to
.
deep
.
equal
({
key1
:
"
value1
"
,
key2
:
"
value2
"
});
it
(
'
should return the custom data
'
,
()
=>
{
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
=
{
aps
:
{
"
content-available
"
:
1
,
'
content-available
'
:
1
,
badge
:
someBadgeCount
},
managedAps
:
{
action
:
"
CREATE
"
,
notificationId
:
"
1
"
,
action
:
'
CREATE
'
,
notificationId
:
'
1
'
,
alert
:
{
title
:
"
some title
"
,
body
:
"
some body
"
title
:
'
some title
'
,
body
:
'
some body
'
},
sound
:
someSound
,
category
:
someCategory
},
key1
:
"
value1
"
,
key2
:
"
value2
"
key1
:
'
value1
'
,
key2
:
'
value2
'
};
beforeEach
(()
=>
{
notification
=
new
IOSNotification
(
managedNativeNotification
);
});
it
(
"
should return 'managed' type
"
,
function
()
{
expect
(
notification
.
getType
()).
to
.
equal
(
"
managed
"
);
it
(
'
should return managed type
'
,
function
()
{
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
);
});
it
(
"
should return the sound
"
,
()
=>
{
it
(
'
should return the sound
'
,
()
=>
{
expect
(
notification
.
getSound
()).
to
.
equal
(
someSound
);
});
it
(
"
should return the badge count
"
,
()
=>
{
it
(
'
should return the badge count
'
,
()
=>
{
expect
(
notification
.
getBadgeCount
()).
to
.
equal
(
someBadgeCount
);
});
it
(
"
should return the category
"
,
()
=>
{
it
(
'
should return the category
'
,
()
=>
{
expect
(
notification
.
getCategory
()).
to
.
equal
(
someCategory
);
});
it
(
"
should return the custom data
"
,
()
=>
{
expect
(
notification
.
getData
()).
to
.
deep
.
equal
({
managedAps
:
managedNativeNotification
.
managedAps
,
key1
:
"
value1
"
,
key2
:
"
value2
"
});
it
(
'
should return the custom data
'
,
()
=>
{
expect
(
notification
.
getData
()).
to
.
deep
.
equal
({
managedAps
:
managedNativeNotification
.
managedAps
,
key1
:
'
value1
'
,
key2
:
'
value2
'
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment