File tree Expand file tree Collapse file tree 4 files changed +59
-4
lines changed Expand file tree Collapse file tree 4 files changed +59
-4
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ const typescriptEslintPrettier = require('eslint-config-prettier/@typescript-esl
44module . exports = {
55 extends : [ '@react-native-community' ] ,
66 overrides : [
7+ {
8+ files : [ './mock.js' ] ,
9+ env : { jest : true } ,
10+ } ,
711 {
812 files : [ '*.ts' , '*.tsx' ] ,
913 // Apply the recommended Typescript defaults and the prettier overrides to all Typescript files
Original file line number Diff line number Diff line change 1+ const { PERMISSIONS , RESULTS } = require ( './lib/commonjs/constants' ) ;
2+ export { PERMISSIONS , RESULTS } ;
3+
4+ export const openSettings = jest . fn ( async ( ) => { } ) ;
5+ export const check = jest . fn ( async permission => RESULTS . GRANTED ) ;
6+ export const request = jest . fn ( async permission => RESULTS . GRANTED ) ;
7+
8+ const notificationOptions = [
9+ 'alert' ,
10+ 'badge' ,
11+ 'sound' ,
12+ 'criticalAlert' ,
13+ 'carPlay' ,
14+ // 'provisional', // excluded as it's not included in NotificationSettings
15+ ] ;
16+
17+ const notificationSettings = {
18+ alert : true ,
19+ badge : true ,
20+ sound : true ,
21+ carPlay : true ,
22+ criticalAlert : true ,
23+ lockScreen : true ,
24+ notificationCenter : true ,
25+ } ;
26+
27+ export const checkNotifications = jest . fn ( async ( ) => ( {
28+ status : RESULTS . GRANTED ,
29+ settings : notificationSettings ,
30+ } ) ) ;
31+
32+ export const requestNotifications = jest . fn ( async options => ( {
33+ status : RESULTS . GRANTED ,
34+ settings : options
35+ . filter ( option => notificationOptions . includes ( option ) )
36+ . reduce ( ( acc , option ) => ( { ...acc , [ option ] : true } ) , {
37+ lockScreen : true ,
38+ notificationCenter : true ,
39+ } ) ,
40+ } ) ) ;
41+
42+ export default {
43+ PERMISSIONS ,
44+ RESULTS ,
45+ openSettings,
46+ check,
47+ request,
48+ checkNotifications,
49+ requestNotifications,
50+ } ;
Original file line number Diff line number Diff line change 2525 " /ios" ,
2626 " /src" ,
2727 " /lib" ,
28- " /*.podspec"
28+ " /*.podspec" ,
29+ " ./mock.js"
2930 ],
3031 "scripts" : {
3132 "start" : " react-native start" ,
Original file line number Diff line number Diff line change @@ -12,18 +12,18 @@ export type NotificationOption =
1212 | 'alert'
1313 | 'badge'
1414 | 'sound'
15- | 'criticalAlert'
1615 | 'carPlay'
16+ | 'criticalAlert'
1717 | 'provisional' ;
1818
1919export interface NotificationSettings {
2020 alert ?: boolean ;
2121 badge ?: boolean ;
2222 sound ?: boolean ;
23- lockScreen ?: boolean ;
2423 carPlay ?: boolean ;
25- notificationCenter ?: boolean ;
2624 criticalAlert ?: boolean ;
25+ lockScreen ?: boolean ;
26+ notificationCenter ?: boolean ;
2727}
2828
2929export interface NotificationsResponse {
You can’t perform that action at this time.
0 commit comments