|
@@ -0,0 +1,50 @@
|
|
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
|
+};
|