forked from wix/react-native-notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotifications.test.js
56 lines (49 loc) · 1.83 KB
/
Notifications.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const Utils = require('./Utils');
const {elementByLabel} = Utils;
describe('Notifications', () => {
beforeEach(async () => {
await device.relaunchApp({delete: true, permissions: {notifications: 'YES'}});
});
describe('Foreground', () => {
it('Should receive notification', async () => {
await device.sendUserNotification(createNotification({link: 'foreground/notification'}));
await linkShouldBeVisible('foreground/notification');
});
it('Should open notification', async () => {
await device.sendUserNotification(createNotification({link: 'foreground/notification/click', showAlert: true}));
await expect(elementByLabel('Notification Clicked: foreground/notification/click')).toBeVisible();
});
});
describe('Background', () => {
it('Should open notification', async () => {
await device.sendToHome();
await expect(elementByLabel('Notification Clicked: background/notification')).toBeNotVisible();
await device.launchApp({newInstance: false, userNotification: createNotification({link: 'background/notification'})});
await expect(elementByLabel('Notification Clicked: background/notification')).toBeVisible();
});
});
describe('Dead state', () => {
it('Should receive notification', async () => {
await device.launchApp({newInstance: true, userNotification: createNotification({link: 'deadState/notification'})});
await linkShouldBeVisible('deadState/notification');
});
});
async function linkShouldBeVisible(link) {
return await expect(elementByLabel(`Extra Link Param: ${link}`)).toBeVisible();
}
});
function createNotification({link, showAlert}) {
return {
trigger: {
type: 'push'
},
title: 'From push',
subtitle: 'Subtitle',
body: 'Body',
badge: 1,
payload: {
link,
showAlert
}
};
}