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
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
...
...
@@ -939,12 +939,6 @@
"uri-js"
:
"^4.2.2"
}
},
"ajv-keywords"
:
{
"version"
:
"3.4.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/ajv-keywords/-/ajv-keywords-3.4.0.tgz"
,
"integrity"
:
"sha1-S4Mee1MUFafMUYzUBOc/YZPGNJ0="
,
"dev"
:
true
},
"ansi"
:
{
"version"
:
"0.3.1"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/ansi/-/ansi-0.3.1.tgz"
,
...
...
@@ -1126,6 +1120,12 @@
"integrity"
:
"sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c="
,
"dev"
:
true
},
"astral-regex"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/astral-regex/-/astral-regex-1.0.0.tgz"
,
"integrity"
:
"sha1-bIw/uCfdQ+45GPJ7gngqt2WKb9k="
,
"dev"
:
true
},
"async"
:
{
"version"
:
"2.6.2"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/async/-/async-2.6.2.tgz"
,
...
...
@@ -2091,18 +2091,18 @@
}
},
"caller-path"
:
{
"version"
:
"
0.1
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/caller-path/-/caller-path-
0.1
.0.tgz"
,
"integrity"
:
"sha1-
lAhe9jWB7NPaqSREqP6U6CV3dR8
="
,
"version"
:
"
2.0
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/caller-path/-/caller-path-
2.0
.0.tgz"
,
"integrity"
:
"sha1-
Ro+DBE42mrIBD6xfBs7uFbsssfQ
="
,
"dev"
:
true
,
"requires"
:
{
"call
sites"
:
"^0.2
.0"
"call
er-callsite"
:
"^2.0
.0"
}
},
"callsites"
:
{
"version"
:
"
0.2
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/callsites/-/callsites-
0.2
.0.tgz"
,
"integrity"
:
"sha1-
r6uWJikQp/M8GaV3WCXGnzTjUMo
="
,
"version"
:
"
3.1
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/callsites/-/callsites-
3.1
.0.tgz"
,
"integrity"
:
"sha1-
s2MKvYlDQy9Us/BRkjjjPNffL3M
="
,
"dev"
:
true
},
"camelcase"
:
{
...
...
@@ -2143,9 +2143,9 @@
}
},
"chardet"
:
{
"version"
:
"0.
4.2
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/chardet/-/chardet-0.
4.2
.tgz"
,
"integrity"
:
"sha1-
tUc7M9yXxCTl2Y3IfVXU2KKci/I
="
,
"version"
:
"0.
7.0
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/chardet/-/chardet-0.
7.0
.tgz"
,
"integrity"
:
"sha1-
kAlISfCTfy7twkJdDSip5fDLrZ4
="
,
"dev"
:
true
},
"chokidar"
:
{
...
...
@@ -2180,12 +2180,6 @@
"yargs"
:
"12.0.5"
}
},
"circular-json"
:
{
"version"
:
"0.3.3"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/circular-json/-/circular-json-0.3.3.tgz"
,
"integrity"
:
"sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY="
,
"dev"
:
true
},
"class-utils"
:
{
"version"
:
"0.3.6"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/class-utils/-/class-utils-0.3.6.tgz"
,
...
...
@@ -2431,6 +2425,24 @@
"is-directory"
:
"^0.3.1"
,
"js-yaml"
:
"^3.13.1"
,
"parse-json"
:
"^4.0.0"
},
"dependencies"
:
{
"import-fresh"
:
{
"version"
:
"2.0.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/import-fresh/-/import-fresh-2.0.0.tgz"
,
"integrity"
:
"sha1-2BNVwVYS04bGH53dOSLUMEgipUY="
,
"dev"
:
true
,
"requires"
:
{
"caller-path"
:
"^2.0.0"
,
"resolve-from"
:
"^3.0.0"
}
},
"resolve-from"
:
{
"version"
:
"3.0.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/resolve-from/-/resolve-from-3.0.0.tgz"
,
"integrity"
:
"sha1-six699nWiBvItuZTM17rywoYh0g="
,
"dev"
:
true
}
}
},
"create-react-class"
:
{
...
...
@@ -2614,9 +2626,9 @@
"dev"
:
true
},
"doctrine"
:
{
"version"
:
"
2.1
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/doctrine/-/doctrine-
2.1
.0.tgz"
,
"integrity"
:
"sha1-
XNAfwQFiG0LEzX9dGmYkNxbT850
="
,
"version"
:
"
3.0
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/doctrine/-/doctrine-
3.0
.0.tgz"
,
"integrity"
:
"sha1-
rd6+rXKmV023g2OdyHoSF3OXOWE
="
,
"dev"
:
true
,
"requires"
:
{
"esutils"
:
"^2.0.2"
...
...
@@ -2634,6 +2646,12 @@
"integrity"
:
"sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
,
"dev"
:
true
},
"emoji-regex"
:
{
"version"
:
"7.0.3"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/emoji-regex/-/emoji-regex-7.0.3.tgz"
,
"integrity"
:
"sha1-kzoEBShgyF6DwSJHnEdIqOTHIVY="
,
"dev"
:
true
},
"encodeurl"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/encodeurl/-/encodeurl-1.0.2.tgz"
,
...
...
@@ -2721,49 +2739,46 @@
"dev"
:
true
},
"eslint"
:
{
"version"
:
"
5.1.0
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/eslint/-/eslint-
5.1.0
.tgz"
,
"integrity"
:
"sha1-
LtYR8c4WPA+5nh4M2lr49mLf9kU
="
,
"version"
:
"
6.0.1
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/eslint/-/eslint-
6.0.1
.tgz"
,
"integrity"
:
"sha1-
SjIYHXLLmZ1vVBUd99M3Ex+Bzac
="
,
"dev"
:
true
,
"requires"
:
{
"
ajv"
:
"^6.5
.0"
,
"
babel-code-frame"
:
"^6.26
.0"
,
"
@babel/code-frame"
:
"^7.0
.0"
,
"
ajv"
:
"^6.10
.0"
,
"chalk"
:
"^2.1.0"
,
"cross-spawn"
:
"^6.0.5"
,
"debug"
:
"^
3.1.0
"
,
"doctrine"
:
"^
2.1
.0"
,
"eslint-scope"
:
"^4.0.
0
"
,
"debug"
:
"^
4.0.1
"
,
"doctrine"
:
"^
3.0
.0"
,
"eslint-scope"
:
"^4.0.
3
"
,
"eslint-utils"
:
"^1.3.1"
,
"eslint-visitor-keys"
:
"^1.0.0"
,
"espree"
:
"^
4
.0.0"
,
"espree"
:
"^
6
.0.0"
,
"esquery"
:
"^1.0.1"
,
"esutils"
:
"^2.0.2"
,
"file-entry-cache"
:
"^
2.0.0
"
,
"file-entry-cache"
:
"^
5.0.1
"
,
"functional-red-black-tree"
:
"^1.0.1"
,
"glob
"
:
"^7.1.2
"
,
"glob
-parent"
:
"^3.1.0
"
,
"globals"
:
"^11.7.0"
,
"ignore"
:
"^3.3.3"
,
"ignore"
:
"^4.0.6"
,
"import-fresh"
:
"^3.0.0"
,
"imurmurhash"
:
"^0.1.4"
,
"inquirer"
:
"^
5.2.0
"
,
"is-
resolvable"
:
"^1.1
.0"
,
"js-yaml"
:
"^3.1
1.0
"
,
"inquirer"
:
"^
6.2.2
"
,
"is-
glob"
:
"^4.0
.0"
,
"js-yaml"
:
"^3.1
3.1
"
,
"json-stable-stringify-without-jsonify"
:
"^1.0.1"
,
"levn"
:
"^0.3.0"
,
"lodash"
:
"^4.17.
5
"
,
"lodash"
:
"^4.17.
11
"
,
"minimatch"
:
"^3.0.4"
,
"mkdirp"
:
"^0.5.1"
,
"natural-compare"
:
"^1.4.0"
,
"optionator"
:
"^0.8.2"
,
"path-is-inside"
:
"^1.0.2"
,
"pluralize"
:
"^7.0.0"
,
"progress"
:
"^2.0.0"
,
"regexpp"
:
"^1.1.0"
,
"require-uncached"
:
"^1.0.3"
,
"semver"
:
"^5.5.0"
,
"string.prototype.matchall"
:
"^2.0.0"
,
"regexpp"
:
"^2.0.1"
,
"semver"
:
"^5.5.1"
,
"strip-ansi"
:
"^4.0.0"
,
"strip-json-comments"
:
"^2.0.1"
,
"table"
:
"^
4.0
.3"
,
"table"
:
"^
5.2
.3"
,
"text-table"
:
"^0.2.0"
},
"dependencies"
:
{
...
...
@@ -2773,15 +2788,6 @@
"integrity"
:
"sha1-7QMXwyIGT3lGbAKWa922Bas32Zg="
,
"dev"
:
true
},
"debug"
:
{
"version"
:
"3.2.6"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/debug/-/debug-3.2.6.tgz"
,
"integrity"
:
"sha1-6D0X3hbYp++3cX7b5fsQE17uYps="
,
"dev"
:
true
,
"requires"
:
{
"ms"
:
"^2.1.1"
}
},
"eslint-scope"
:
{
"version"
:
"4.0.3"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/eslint-scope/-/eslint-scope-4.0.3.tgz"
,
...
...
@@ -2826,12 +2832,12 @@
"dev"
:
true
},
"espree"
:
{
"version"
:
"
4.1
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/espree/-/espree-
4.1
.0.tgz"
,
"integrity"
:
"sha1-c
o1UUeD9FWwEOEp62J7VH/VOsl8
="
,
"version"
:
"
6.0
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/espree/-/espree-
6.0
.0.tgz"
,
"integrity"
:
"sha1-c
W/B9aJF71uaf9sdew0/AjIudfY
="
,
"dev"
:
true
,
"requires"
:
{
"acorn"
:
"^6.0.
2
"
,
"acorn"
:
"^6.0.
7
"
,
"acorn-jsx"
:
"^5.0.0"
,
"eslint-visitor-keys"
:
"^1.0.0"
}
...
...
@@ -3037,13 +3043,13 @@
}
},
"external-editor"
:
{
"version"
:
"
2.2.0
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/external-editor/-/external-editor-
2.2.0
.tgz"
,
"integrity"
:
"sha1-
BFURz9jRM/OEZnPRBHwVTiFK09U
="
,
"version"
:
"
3.0.3
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/external-editor/-/external-editor-
3.0.3
.tgz"
,
"integrity"
:
"sha1-
WGbbKal4Jtvkvzr9JAcOrZ6kOic
="
,
"dev"
:
true
,
"requires"
:
{
"chardet"
:
"^0.
4
.0"
,
"iconv-lite"
:
"^0.4.
17
"
,
"chardet"
:
"^0.
7
.0"
,
"iconv-lite"
:
"^0.4.
24
"
,
"tmp"
:
"^0.0.33"
}
},
...
...
@@ -3238,13 +3244,12 @@
}
},
"file-entry-cache"
:
{
"version"
:
"
2.0.0
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/file-entry-cache/-/file-entry-cache-
2.0.0
.tgz"
,
"integrity"
:
"sha1-
w5KZDD5oR4PYOLjISkXYoEhFg2E
="
,
"version"
:
"
5.0.1
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/file-entry-cache/-/file-entry-cache-
5.0.1
.tgz"
,
"integrity"
:
"sha1-
yg9u+m3T1WEzP7FFFQZcL6/fQ5w
="
,
"dev"
:
true
,
"requires"
:
{
"flat-cache"
:
"^1.2.1"
,
"object-assign"
:
"^4.0.1"
"flat-cache"
:
"^2.0.1"
}
},
"filename-regex"
:
{
...
...
@@ -3339,17 +3344,22 @@
}
},
"flat-cache"
:
{
"version"
:
"
1.3.4
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/flat-cache/-/flat-cache-
1.3.4
.tgz"
,
"integrity"
:
"sha1-
LC73dSXMKSkAff/6HdMUqpyd7m8
="
,
"version"
:
"
2.0.1
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/flat-cache/-/flat-cache-
2.0.1
.tgz"
,
"integrity"
:
"sha1-
XSltbwS9pEpGMKMBQTvbwuwIXsA
="
,
"dev"
:
true
,
"requires"
:
{
"circular-json"
:
"^0.3.1"
,
"graceful-fs"
:
"^4.1.2"
,
"rimraf"
:
"~2.6.2"
,
"write"
:
"^0.2.1"
"flatted"
:
"^2.0.0"
,
"rimraf"
:
"2.6.3"
,
"write"
:
"1.0.3"
}
},
"flatted"
:
{
"version"
:
"2.0.1"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/flatted/-/flatted-2.0.1.tgz"
,
"integrity"
:
"sha1-aeV8qo8OrLwoHS4stFjUb9tEngg="
,
"dev"
:
true
},
"for-in"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/for-in/-/for-in-1.0.2.tgz"
,
...
...
@@ -4212,9 +4222,9 @@
}
},
"ignore"
:
{
"version"
:
"
3.3.10
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/ignore/-/ignore-
3.3.10
.tgz"
,
"integrity"
:
"sha1-
Cpf7h2mG6AgcYxFg+PnziRV/AEM
="
,
"version"
:
"
4.0.6
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/ignore/-/ignore-
4.0.6
.tgz"
,
"integrity"
:
"sha1-
dQ49tYYgh7RzfrrIIH/9HvJ7Jfw
="
,
"dev"
:
true
},
"image-size"
:
{
...
...
@@ -4224,30 +4234,13 @@
"dev"
:
true
},
"import-fresh"
:
{
"version"
:
"
2.0
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/import-fresh/-/import-fresh-
2.0
.0.tgz"
,
"integrity"
:
"sha1-
2BNVwVYS04bGH53dOSLUMEgipUY
="
,
"version"
:
"
3.1
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/import-fresh/-/import-fresh-
3.1
.0.tgz"
,
"integrity"
:
"sha1-
bTP6Hc7235MPrgA0RvM0Fa+QURg
="
,
"dev"
:
true
,
"requires"
:
{
"caller-path"
:
"^2.0.0"
,
"resolve-from"
:
"^3.0.0"
},
"dependencies"
:
{
"caller-path"
:
{
"version"
:
"2.0.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/caller-path/-/caller-path-2.0.0.tgz"
,
"integrity"
:
"sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ="
,
"dev"
:
true
,
"requires"
:
{
"caller-callsite"
:
"^2.0.0"
}
},
"resolve-from"
:
{
"version"
:
"3.0.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/resolve-from/-/resolve-from-3.0.0.tgz"
,
"integrity"
:
"sha1-six699nWiBvItuZTM17rywoYh0g="
,
"dev"
:
true
}
"parent-module"
:
"^1.0.0"
,
"resolve-from"
:
"^4.0.0"
}
},
"imurmurhash"
:
{
...
...
@@ -4273,39 +4266,39 @@
"dev"
:
true
},
"inquirer"
:
{
"version"
:
"
5.2.0
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/inquirer/-/inquirer-
5.2.0
.tgz"
,
"integrity"
:
"sha1-
2zUMK3Paynf/EkOWLp8i8JloVyY
="
,
"version"
:
"
6.4.1
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/inquirer/-/inquirer-
6.4.1
.tgz"
,
"integrity"
:
"sha1-
e9nlqwVnzSO0GwGAto4M+oL8PAs
="
,
"dev"
:
true
,
"requires"
:
{
"ansi-escapes"
:
"^3.
0
.0"
,
"chalk"
:
"^2.
0.0
"
,
"ansi-escapes"
:
"^3.
2
.0"
,
"chalk"
:
"^2.
4.2
"
,
"cli-cursor"
:
"^2.1.0"
,
"cli-width"
:
"^2.0.0"
,
"external-editor"
:
"^
2.1.0
"
,
"external-editor"
:
"^
3.0.3
"
,
"figures"
:
"^2.0.0"
,
"lodash"
:
"^4.
3.0
"
,
"lodash"
:
"^4.
17.11
"
,
"mute-stream"
:
"0.0.7"
,
"run-async"
:
"^2.2.0"
,
"rxjs"
:
"^
5.5.2
"
,
"rxjs"
:
"^
6.4.0
"
,
"string-width"
:
"^2.1.0"
,
"strip-ansi"
:
"^
4.0
.0"
,
"strip-ansi"
:
"^
5.1
.0"
,
"through"
:
"^2.3.6"
},
"dependencies"
:
{
"ansi-regex"
:
{
"version"
:
"
3.0
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/ansi-regex/-/ansi-regex-
3.0
.0.tgz"
,
"integrity"
:
"sha1-
7QMXwyIGT3lGbAKWa922Bas32Zg
="
,
"version"
:
"
4.1
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/ansi-regex/-/ansi-regex-
4.1
.0.tgz"
,
"integrity"
:
"sha1-
i5+PCM8ay4Q3Vqg5yox+MWjFGZc
="
,
"dev"
:
true
},
"strip-ansi"
:
{
"version"
:
"
4.0
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/strip-ansi/-/strip-ansi-
4.0
.0.tgz"
,
"integrity"
:
"sha1-
qEeQIusaw2iocTibY1JixQXuNo8
="
,
"version"
:
"
5.2
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/strip-ansi/-/strip-ansi-
5.2
.0.tgz"
,
"integrity"
:
"sha1-
jJpTb+tq/JYr36WxBKUJHBrZwK4
="
,
"dev"
:
true
,
"requires"
:
{
"ansi-regex"
:
"^
3.0
.0"
"ansi-regex"
:
"^
4.1
.0"
}
}
}
...
...
@@ -4548,12 +4541,6 @@
"has"
:
"^1.0.1"
}
},
"is-resolvable"
:
{
"version"
:
"1.1.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/is-resolvable/-/is-resolvable-1.1.0.tgz"
,
"integrity"
:
"sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg="
,
"dev"
:
true
},
"is-stream"
:
{
"version"
:
"1.1.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/is-stream/-/is-stream-1.1.0.tgz"
,
...
...
@@ -6112,6 +6099,15 @@
"integrity"
:
"sha1-yyhoVA4xPWHeWPr741zpAE1VQOY="
,
"dev"
:
true
},
"parent-module"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/parent-module/-/parent-module-1.0.1.tgz"
,
"integrity"
:
"sha1-aR0nCeeMefrjoVZiJFLQB2LKqqI="
,
"dev"
:
true
,
"requires"
:
{
"callsites"
:
"^3.0.0"
}
},
"parse-glob"
:
{
"version"
:
"3.0.4"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/parse-glob/-/parse-glob-3.0.4.tgz"
,
...
...
@@ -6187,12 +6183,6 @@
"integrity"
:
"sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
,
"dev"
:
true
},
"path-is-inside"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/path-is-inside/-/path-is-inside-1.0.2.tgz"
,
"integrity"
:
"sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM="
,
"dev"
:
true
},
"path-key"
:
{
"version"
:
"2.0.1"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/path-key/-/path-key-2.0.1.tgz"
,
...
...
@@ -6295,12 +6285,6 @@
}
}
},
"pluralize"
:
{
"version"
:
"7.0.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/pluralize/-/pluralize-7.0.0.tgz"
,
"integrity"
:
"sha1-KYuJ34uTsCIdv0Ia0rGx6iP8Z3c="
,
"dev"
:
true
},
"posix-character-classes"
:
{
"version"
:
"0.1.1"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/posix-character-classes/-/posix-character-classes-0.1.1.tgz"
,
...
...
@@ -6577,6 +6561,12 @@
"supports-color"
:
"^2.0.0"
}
},
"chardet"
:
{
"version"
:
"0.4.2"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/chardet/-/chardet-0.4.2.tgz"
,
"integrity"
:
"sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I="
,
"dev"
:
true
},
"cliui"
:
{
"version"
:
"3.2.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/cliui/-/cliui-3.2.0.tgz"
,
...
...
@@ -6642,6 +6632,17 @@
"strip-eof"
:
"^1.0.0"
}
},
"external-editor"
:
{
"version"
:
"2.2.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/external-editor/-/external-editor-2.2.0.tgz"
,
"integrity"
:
"sha1-BFURz9jRM/OEZnPRBHwVTiFK09U="
,
"dev"
:
true
,
"requires"
:
{
"chardet"
:
"^0.4.0"
,
"iconv-lite"
:
"^0.4.17"
,
"tmp"
:
"^0.0.33"
}
},
"get-stream"
:
{
"version"
:
"3.0.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/get-stream/-/get-stream-3.0.0.tgz"
,
...
...
@@ -6995,19 +6996,10 @@
"safe-regex"
:
"^1.1.0"
}
},
"regexp.prototype.flags"
:
{
"version"
:
"1.2.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/regexp.prototype.flags/-/regexp.prototype.flags-1.2.0.tgz"
,
"integrity"
:
"sha1-azByTjBqJ4M+6xcbZqyIkLo35Bw="
,
"dev"
:
true
,
"requires"
:
{
"define-properties"
:
"^1.1.2"
}
},
"regexpp"
:
{
"version"
:
"
1.1.0
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/regexpp/-/regexpp-
1.1.0
.tgz"
,
"integrity"
:
"sha1-
DjUW3Qt5BPQT0tQZPc5GGMOmias
="
,
"version"
:
"
2.0.1
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/regexpp/-/regexpp-
2.0.1
.tgz"
,
"integrity"
:
"sha1-
jRnTHPYySCtYkEn4KB+T28uk0H8
="
,
"dev"
:
true
},
"regexpu-core"
:
{
...
...
@@ -7086,16 +7078,6 @@
"integrity"
:
"sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE="
,
"dev"
:
true
},
"require-uncached"
:
{
"version"
:
"1.0.3"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/require-uncached/-/require-uncached-1.0.3.tgz"
,
"integrity"
:
"sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM="
,
"dev"
:
true
,
"requires"
:
{
"caller-path"
:
"^0.1.0"
,
"resolve-from"
:
"^1.0.0"
}
},
"resolve"
:
{
"version"
:
"1.1.7"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/resolve/-/resolve-1.1.7.tgz"
,
...
...
@@ -7103,9 +7085,9 @@
"dev"
:
true
},
"resolve-from"
:
{
"version"
:
"
1.0.1
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/resolve-from/-/resolve-from-
1.0.1
.tgz"
,
"integrity"
:
"sha1-
Jsv+k10a7uq7Kbw/5a6wHpPUQi
Y="
,
"version"
:
"
4.0.0
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/resolve-from/-/resolve-from-
4.0.0
.tgz"
,
"integrity"
:
"sha1-
SrzYUq0y3Xuqv+m0DgCjbbXzku
Y="
,
"dev"
:
true
},
"resolve-url"
:
{
...
...
@@ -7170,12 +7152,12 @@
}
},
"rxjs"
:
{
"version"
:
"
5.5.1
2"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/rxjs/-/rxjs-
5.5.1
2.tgz"
,
"integrity"
:
"sha1-
b6YbinfD15PbrycL7i9D9lLXQcw
="
,
"version"
:
"
6.5.
2"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/rxjs/-/rxjs-
6.5.
2.tgz"
,
"integrity"
:
"sha1-
LjXOgVzUbYTQKiCftOWSHgUdvsc
="
,
"dev"
:
true
,
"requires"
:
{
"
symbol-observable"
:
"1.0.1
"
"
tslib"
:
"^1.9.0
"
}
},
"safe-buffer"
:
{
...
...
@@ -7472,11 +7454,13 @@
"dev"
:
true
},
"slice-ansi"
:
{
"version"
:
"
1.0
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/slice-ansi/-/slice-ansi-
1.0
.0.tgz"
,
"integrity"
:
"sha1-
BE8aSdiEL/MHqta1Be0Xi9lQE00
="
,
"version"
:
"
2.1
.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/slice-ansi/-/slice-ansi-
2.1
.0.tgz"
,
"integrity"
:
"sha1-
ys12k0YaY3pXiNkqfdT7oGjoFjY
="
,
"dev"
:
true
,
"requires"
:
{
"ansi-styles"
:
"^3.2.0"
,
"astral-regex"
:
"^1.0.0"
,
"is-fullwidth-code-point"
:
"^2.0.0"
}
},
...
...
@@ -7758,19 +7742,6 @@
}
}
},
"string.prototype.matchall"
:
{
"version"
:
"2.0.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/string.prototype.matchall/-/string.prototype.matchall-2.0.0.tgz"
,
"integrity"
:
"sha1-Kvj+PS1txTyipZvTdrCJw8FSs8g="
,
"dev"
:
true
,
"requires"
:
{
"define-properties"
:
"^1.1.2"
,
"es-abstract"
:
"^1.10.0"
,
"function-bind"
:
"^1.1.1"
,
"has-symbols"
:
"^1.0.0"
,
"regexp.prototype.flags"
:
"^1.2.0"
}
},
"string_decoder"
:
{
"version"
:
"1.1.1"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/string_decoder/-/string_decoder-1.1.1.tgz"
,
...
...
@@ -7816,24 +7787,44 @@
"has-flag"
:
"^3.0.0"
}
},
"symbol-observable"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/symbol-observable/-/symbol-observable-1.0.1.tgz"
,
"integrity"
:
"sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ="
,
"dev"
:
true
},
"table"
:
{
"version"
:
"
4.0.3
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/table/-/table-
4.0.3
.tgz"
,
"integrity"
:
"sha1-
ALXitgLxeUuayvnKkIp2OGp4E7w
="
,
"version"
:
"
5.4.1
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/table/-/table-
5.4.1
.tgz"
,
"integrity"
:
"sha1-
BpGuLr6CWYWO+2PlULbV+TABceg
="
,
"dev"
:
true
,
"requires"
:
{
"ajv"
:
"^6.0.1"
,
"ajv-keywords"
:
"^3.0.0"
,
"chalk"
:
"^2.1.0"
,
"lodash"
:
"^4.17.4"
,
"slice-ansi"
:
"1.0.0"
,
"string-width"
:
"^2.1.1"
"ajv"
:
"^6.9.1"
,
"lodash"
:
"^4.17.11"
,
"slice-ansi"
:
"^2.1.0"
,
"string-width"
:
"^3.0.0"
},
"dependencies"
:
{
"ansi-regex"
:
{
"version"
:
"4.1.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/ansi-regex/-/ansi-regex-4.1.0.tgz"
,
"integrity"
:
"sha1-i5+PCM8ay4Q3Vqg5yox+MWjFGZc="
,
"dev"
:
true
},
"string-width"
:
{
"version"
:
"3.1.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/string-width/-/string-width-3.1.0.tgz"
,
"integrity"
:
"sha1-InZ74htirxCBV0MG9prFG2IgOWE="
,
"dev"
:
true
,
"requires"
:
{
"emoji-regex"
:
"^7.0.1"
,
"is-fullwidth-code-point"
:
"^2.0.0"
,
"strip-ansi"
:
"^5.1.0"
}
},
"strip-ansi"
:
{
"version"
:
"5.2.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/strip-ansi/-/strip-ansi-5.2.0.tgz"
,
"integrity"
:
"sha1-jJpTb+tq/JYr36WxBKUJHBrZwK4="
,
"dev"
:
true
,
"requires"
:
{
"ansi-regex"
:
"^4.1.0"
}
}
}
},
"temp"
:
{
...
...
@@ -7969,6 +7960,12 @@
"integrity"
:
"sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM="
,
"dev"
:
true
},
"tslib"
:
{
"version"
:
"1.10.0"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/tslib/-/tslib-1.10.0.tgz"
,
"integrity"
:
"sha1-w8GflZc/sKYpc/sJ2Q2WHuQ+XIo="
,
"dev"
:
true
},
"type-check"
:
{
"version"
:
"0.3.2"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/type-check/-/type-check-0.3.2.tgz"
,
...
...
@@ -8292,9 +8289,9 @@
"dev"
:
true
},
"write"
:
{
"version"
:
"
0.2.1
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/write/-/write-
0.2.1
.tgz"
,
"integrity"
:
"sha1-
X8A4KOJkzqP+kUVUdvejxWbLB1c
="
,
"version"
:
"
1.0.3
"
,
"resolved"
:
"https://repo.dev.wixpress.com/artifactory/api/npm/npm-repos/write/-/write-
1.0.3
.tgz"
,
"integrity"
:
"sha1-
CADhRSO5I6OH5BUSPIZWFqrg9cM
="
,
"dev"
:
true
,
"requires"
:
{
"mkdirp"
:
"^0.5.1"
...
...
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
"
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
'
;
/* eslint-disable no-unused-vars */
describe
(
"
NotificationsIOS
"
,
()
=>
{
describe
(
'
NotificationsIOS
'
,
()
=>
{
let
deviceEvents
=
[
"
pushKitRegistered
"
,
"
remoteNotificationsRegistered
"
,
"
remoteNotificationsRegistrationFailed
"
,
"
notificationReceivedForeground
"
,
"
notificationReceivedBackground
"
,
"
notificationOpened
"
'
pushKitRegistered
'
,
'
remoteNotificationsRegistered
'
,
'
remoteNotificationsRegistrationFailed
'
,
'
notificationReceivedForeground
'
,
'
notificationReceivedBackground
'
,
'
notificationOpened
'
];
/*eslint-disable indent*/
...
...
@@ -38,8 +38,8 @@ describe("NotificationsIOS", () => {
let
NotificationsIOS
,
NotificationAction
,
NotificationCategory
;
let
someHandler
=
()
=>
{};
let
constantGuid
=
"
some-random-uuid
"
;
let
identifiers
=
[
"
some-random-uuid
"
,
"
other-random-uuid
"
];
let
constantGuid
=
'
some-random-uuid
'
;
let
identifiers
=
[
'
some-random-uuid
'
,
'
other-random-uuid
'
];
/*eslint-enable indent*/
before
(()
=>
{
...
...
@@ -63,11 +63,11 @@ describe("NotificationsIOS", () => {
nativeRemoveDeliveredNotifications
=
sinon
.
spy
();
nativeGetDeliveredNotifications
=
sinon
.
spy
();
let
libUnderTest
=
proxyquire
(
"
../index.ios
"
,
{
"
uuid
"
:
{
let
libUnderTest
=
proxyquire
(
'
../index.ios
'
,
{
'
uuid
'
:
{
v4
:
()
=>
constantGuid
},
"
react-native
"
:
{
'
react-native
'
:
{
NativeModules
:
{
RNBridgeModule
:
{
requestPermissionsWithCategories
:
nativeRequestPermissionsWithCategories
,
...
...
@@ -101,7 +101,7 @@ describe("NotificationsIOS", () => {
return
{
remove
:
deviceRemoveEventListener
};
}
},
"
@noCallThru
"
:
true
'
@noCallThru
'
:
true
}
});
...
...
@@ -154,7 +154,7 @@ describe("NotificationsIOS", () => {
NotificationCategory
=
null
;
});
describe
(
"
Add Event Listener
"
,
()
=>
{
describe
(
'
Add Event Listener
'
,
()
=>
{
deviceEvents
.
forEach
(
event
=>
{
it
(
`should subscribe the given handler to device event:
${
event
}
`
,
()
=>
{
NotificationsIOS
.
addEventListener
(
event
,
someHandler
);
...
...
@@ -163,14 +163,14 @@ describe("NotificationsIOS", () => {
});
});
it
(
"
should not subscribe to unknown device events
"
,
()
=>
{
NotificationsIOS
.
addEventListener
(
"
someUnsupportedEvent
"
,
someHandler
);
it
(
'
should not subscribe to unknown device events
'
,
()
=>
{
NotificationsIOS
.
addEventListener
(
'
someUnsupportedEvent
'
,
someHandler
);
expect
(
deviceAddEventListener
).
to
.
not
.
have
.
been
.
called
;
});
});
describe
(
"
Remove Event Listener
"
,
()
=>
{
describe
(
'
Remove Event Listener
'
,
()
=>
{
deviceEvents
.
forEach
(
event
=>
{
it
(
`should unsubscribe the given handler from device event:
${
event
}
`
,
()
=>
{
NotificationsIOS
.
addEventListener
(
event
,
someHandler
);
...
...
@@ -180,8 +180,8 @@ describe("NotificationsIOS", () => {
});
});
it
(
"
should not unsubscribe to unknown device events
"
,
()
=>
{
let
someUnsupportedEvent
=
"
someUnsupportedEvent
"
;
it
(
'
should not unsubscribe to unknown device events
'
,
()
=>
{
let
someUnsupportedEvent
=
'
someUnsupportedEvent
'
;
NotificationsIOS
.
addEventListener
(
someUnsupportedEvent
,
someHandler
);
NotificationsIOS
.
removeEventListener
(
someUnsupportedEvent
,
someHandler
);
...
...
@@ -189,61 +189,61 @@ describe("NotificationsIOS", () => {
});
});
describe
(
"
Notification actions handling
"
,
()
=>
{
describe
(
'
Notification actions handling
'
,
()
=>
{
let
someAction
,
someCategory
;
let
actionOpts
=
{
activationMode
:
"
foreground
"
,
title
:
"
someAction
"
,
behavior
:
"
default
"
,
identifier
:
"
SOME_ACTION
"
activationMode
:
'
foreground
'
,
title
:
'
someAction
'
,
behavior
:
'
default
'
,
identifier
:
'
SOME_ACTION
'
};
beforeEach
(()
=>
{
someAction
=
new
NotificationAction
(
actionOpts
,
()
=>
{});
someCategory
=
new
NotificationCategory
({
identifier
:
"
SOME_CATEGORY
"
,
identifier
:
'
SOME_CATEGORY
'
,
actions
:
[
someAction
],
context
:
"
default
"
context
:
'
default
'
});
});
describe
(
"
register push notifications
"
,
()
=>
{
it
(
"
should call native request permissions with array of categories
"
,
()
=>
{
describe
(
'
register push notifications
'
,
()
=>
{
it
(
'
should call native request permissions with array of categories
'
,
()
=>
{
NotificationsIOS
.
requestPermissions
([
someCategory
]);
expect
(
nativeRequestPermissionsWithCategories
).
to
.
have
.
been
.
calledWith
([{
identifier
:
"
SOME_CATEGORY
"
,
identifier
:
'
SOME_CATEGORY
'
,
actions
:
[
actionOpts
],
context
:
"
default
"
context
:
'
default
'
}]);
});
it
(
"
should call native request permissions with empty array if no categories specified
"
,
()
=>
{
it
(
'
should call native request permissions with empty array if no categories specified
'
,
()
=>
{
NotificationsIOS
.
requestPermissions
();
expect
(
nativeRequestPermissionsWithCategories
).
to
.
have
.
been
.
calledWith
([]);
});
it
(
"
should subscribe to 'notificationActionReceived' event once, with a single event handler
"
,
()
=>
{
it
(
'
should subscribe to notificationActionReceived event once, with a single event handler
'
,
()
=>
{
NotificationsIOS
.
requestPermissions
([
someCategory
]);
expect
(
nativeAppAddEventListener
).
to
.
have
.
been
.
calledOnce
;
expect
(
nativeAppAddEventListener
).
to
.
have
.
been
.
calledWith
(
"
notificationActionReceived
"
,
sinon
.
match
.
func
);
expect
(
nativeAppAddEventListener
).
to
.
have
.
been
.
calledWith
(
'
notificationActionReceived
'
,
sinon
.
match
.
func
);
});
});
describe
(
"
reset categories
"
,
()
=>
{
it
(
"
should remove 'notificationActionReceived' event handler
"
,
()
=>
{
describe
(
'
reset categories
'
,
()
=>
{
it
(
'
should remove notificationActionReceived event handler
'
,
()
=>
{
NotificationsIOS
.
resetCategories
();
expect
(
nativeAppRemoveEventListener
).
to
.
have
.
been
.
calledOnce
;
});
});
describe
(
"
get badges count
"
,
()
=>
{
it
(
"
should call native getBadgesCount
"
,
()
=>
{
describe
(
'
get badges count
'
,
()
=>
{
it
(
'
should call native getBadgesCount
'
,
()
=>
{
const
callback
=
(
count
)
=>
console
.
log
(
count
);
NotificationsIOS
.
getBadgesCount
(
callback
);
...
...
@@ -251,8 +251,8 @@ describe("NotificationsIOS", () => {
});
});
describe
(
"
set badges count
"
,
()
=>
{
it
(
"
should call native setBadgesCount
"
,
()
=>
{
describe
(
'
set badges count
'
,
()
=>
{
it
(
'
should call native setBadgesCount
'
,
()
=>
{
NotificationsIOS
.
setBadgesCount
(
44
);
expect
(
nativeSetBadgesCount
).
to
.
have
.
been
.
calledWith
(
44
);
...
...
@@ -261,24 +261,24 @@ describe("NotificationsIOS", () => {
});
describe
(
"
register push kit for background notifications
"
,
function
()
{
it
(
"
should call native register push kit method
"
,
function
()
{
describe
(
'
register push kit for background notifications
'
,
function
()
{
it
(
'
should call native register push kit method
'
,
function
()
{
NotificationsIOS
.
registerPushKit
();
expect
(
nativeRegisterPushKit
).
to
.
have
.
been
.
called
;
});
});
describe
(
"
Abandon push notifications permissions
"
,
()
=>
{
it
(
"
should call native abandon permissions method
"
,
()
=>
{
describe
(
'
Abandon push notifications permissions
'
,
()
=>
{
it
(
'
should call native abandon permissions method
'
,
()
=>
{
NotificationsIOS
.
abandonPermissions
();
expect
(
nativeAbandonPermissions
).
to
.
have
.
been
.
called
;
});
});
describe
(
"
Get background remaining time
"
,
()
=>
{
it
(
"
should call native background remaining time method
"
,
()
=>
{
describe
(
'
Get background remaining time
'
,
()
=>
{
it
(
'
should call native background remaining time method
'
,
()
=>
{
let
someCallback
=
(
time
)
=>
{
};
NotificationsIOS
.
backgroundTimeRemaining
(
someCallback
);
...
...
@@ -287,20 +287,20 @@ describe("NotificationsIOS", () => {
});
});
describe
(
"
Dispatch local notification
"
,
()
=>
{
it
(
"
should return generated notification guid
"
,
()
=>
{
describe
(
'
Dispatch local notification
'
,
()
=>
{
it
(
'
should return generated notification guid
'
,
()
=>
{
expect
(
NotificationsIOS
.
localNotification
({})).
to
.
equal
(
constantGuid
);
});
it
(
"
should call native local notification method with generated notification guid and notification object
"
,
()
=>
{
it
(
'
should call native local notification method with generated notification guid and notification object
'
,
()
=>
{
let
someLocalNotification
=
{
alertBody
:
"
some body
"
,
alertTitle
:
"
some title
"
,
alertAction
:
"
some action
"
,
soundName
:
"
sound
"
,
category
:
"
SOME_CATEGORY
"
,
alertBody
:
'
some body
'
,
alertTitle
:
'
some title
'
,
alertAction
:
'
some action
'
,
soundName
:
'
sound
'
,
category
:
'
SOME_CATEGORY
'
,
userInfo
:
{
"
key
"
:
"
value
"
'
key
'
:
'
value
'
}
};
...
...
@@ -310,56 +310,56 @@ describe("NotificationsIOS", () => {
});
});
describe
(
"
Cancel local notification
"
,
()
=>
{
it
(
"
should call native cancel local notification method
"
,
()
=>
{
describe
(
'
Cancel local notification
'
,
()
=>
{
it
(
'
should call native cancel local notification method
'
,
()
=>
{
NotificationsIOS
.
cancelLocalNotification
(
constantGuid
);
expect
(
nativeCancelLocalNotification
).
to
.
have
.
been
.
calledWith
(
constantGuid
);
});
});
describe
(
"
Cancel all local notifications
"
,
()
=>
{
it
(
"
should call native cancel all local notifications method
"
,
()
=>
{
describe
(
'
Cancel all local notifications
'
,
()
=>
{
it
(
'
should call native cancel all local notifications method
'
,
()
=>
{
NotificationsIOS
.
cancelAllLocalNotifications
();
expect
(
nativeCancelAllLocalNotifications
).
to
.
have
.
been
.
calledWith
();
});
});
describe
(
"
Is registered for remote notifications
"
,
()
=>
{
it
(
"
should call native is registered for remote notifications
"
,
()
=>
{
describe
(
'
Is registered for remote notifications
'
,
()
=>
{
it
(
'
should call native is registered for remote notifications
'
,
()
=>
{
NotificationsIOS
.
isRegisteredForRemoteNotifications
();
expect
(
nativeIsRegisteredForRemoteNotifications
).
to
.
have
.
been
.
calledWith
();
});
});
describe
(
"
Check permissions
"
,
()
=>
{
it
(
"
should call native check permissions
"
,
()
=>
{
describe
(
'
Check permissions
'
,
()
=>
{
it
(
'
should call native check permissions
'
,
()
=>
{
NotificationsIOS
.
checkPermissions
();
expect
(
nativeCheckPermissions
).
to
.
have
.
been
.
calledWith
();
});
});
describe
(
"
Remove all delivered notifications
"
,
()
=>
{
it
(
"
should call native remove all delivered notifications method
"
,
()
=>
{
describe
(
'
Remove all delivered notifications
'
,
()
=>
{
it
(
'
should call native remove all delivered notifications method
'
,
()
=>
{
NotificationsIOS
.
removeAllDeliveredNotifications
();
expect
(
nativeRemoveAllDeliveredNotifications
).
to
.
have
.
been
.
calledWith
();
});
});
describe
(
"
Remove delivered notifications
"
,
()
=>
{
it
(
"
should call native remove delivered notifications method
"
,
()
=>
{
describe
(
'
Remove delivered notifications
'
,
()
=>
{
it
(
'
should call native remove delivered notifications method
'
,
()
=>
{
NotificationsIOS
.
removeDeliveredNotifications
(
identifiers
);
expect
(
nativeRemoveDeliveredNotifications
).
to
.
have
.
been
.
calledWith
(
identifiers
);
});
});
describe
(
"
Get delivered notifications
"
,
()
=>
{
it
(
"
should call native get delivered notifications method
"
,
()
=>
{
describe
(
'
Get delivered notifications
'
,
()
=>
{
it
(
'
should call native get delivered notifications method
'
,
()
=>
{
const
callback
=
(
notifications
)
=>
console
.
log
(
notifications
);
NotificationsIOS
.
getDeliveredNotifications
(
callback
);
...
...
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