forked from wix/Detox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
15.urls.test.js
53 lines (47 loc) · 1.74 KB
/
15.urls.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
describe('Open URLs', () => {
afterAll(async () => {
await device.launchApp({
newInstance: true,
url: undefined,
launchArgs: undefined,
});
});
const withDefaultArgs = () => ({
url: 'detoxtesturlscheme://such-string',
launchArgs: undefined,
});
const withSingleInstanceActivityArgs = () => ({
url: 'detoxtesturlscheme.singleinstance://such-string',
launchArgs: { detoxAndroidSingleInstanceActivity: true },
});
[
{
platform: '',
...withDefaultArgs(),
},
{
platform: 'android',
...withSingleInstanceActivityArgs(),
}
].forEach((testSpec) => {
const {platform, url, launchArgs} = testSpec;
const _platform = platform ? `:${platform}: ` : '';
it(`${_platform}device.launchApp() with a URL and a fresh app should launch app and trigger handling open url handling in app`, async () => {
await device.launchApp({newInstance: true, url, launchArgs});
await expect(element(by.text(url))).toBeVisible();
});
it(`${_platform}device.openURL() should trigger open url handling in app when app is in foreground`, async () => {
await device.launchApp({newInstance: true, launchArgs});
await expect(element(by.text(url))).toBeNotVisible();
await device.openURL({url});
await expect(element(by.text(url))).toBeVisible();
});
it(`${_platform}device.launchApp() with a URL should trigger url handling when app is in background`, async () => {
await device.launchApp({newInstance: true, launchArgs});
await expect(element(by.text(url))).toBeNotVisible();
await device.sendToHome();
await device.launchApp({newInstance: false, url});
await expect(element(by.text(url))).toBeVisible();
});
});
});