-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy path16-location.js
38 lines (34 loc) · 1.24 KB
/
16-location.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
const exec = require('child-process-promise').exec;
//TODO: Ignoring the test in CI until fbsimctl supports Xcode 9
async function isFbsimctlInstalled() {
try {
await exec(`which fbsimctl`);
return true;
} catch (e) {
console.log(`setLocation only works through fbsimctl currently`);
return false;
}
}
describe(':ios: location', () => {
it('Location should be unavabilable', async () => {
if (!await isFbsimctlInstalled()) {
return;
}
await device.relaunchApp({ permissions: { location: 'never' } });
await element(by.text('Location')).tap();
await element(by.id('getLocationButton')).tap();
await expect(element(by.id('error'))).toBeVisible();
});
it('Should receive location (20,20)', async () => {
if (!await isFbsimctlInstalled()) {
return;
}
await device.relaunchApp({ permissions: { location: 'always' } });
await device.setLocation(20.1, 20.2);
await element(by.text('Location')).tap();
await element(by.id('getLocationButton')).tap();
await waitFor(element(by.text('Latitude: 20.1'))).toBeVisible().withTimeout(3000);
await expect(element(by.text('Latitude: 20.1'))).toBeVisible();
await expect(element(by.text('Longitude: 20.2'))).toBeVisible();
});
});