forked from expo/expo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestUtils.js
More file actions
44 lines (36 loc) · 1.01 KB
/
Copy pathTestUtils.js
File metadata and controls
44 lines (36 loc) · 1.01 KB
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
'use strict';
import { UnavailabilityError } from 'expo-modules-core';
import ExponentTest from './ExponentTest';
export async function acceptPermissionsAndRunCommandAsync(fn) {
if (!ExponentTest) {
return await fn();
}
const results = await Promise.all([
ExponentTest.action({
selectorType: 'text',
selectorValue: 'Allow',
actionType: 'click',
delay: 1000,
timeout: 100,
}),
fn(),
]);
return results[1];
}
export async function shouldSkipTestsRequiringPermissionsAsync() {
if (!ExponentTest || !ExponentTest.shouldSkipTestsRequiringPermissionsAsync) {
return false;
}
return ExponentTest.shouldSkipTestsRequiringPermissionsAsync();
}
export async function expectMethodToBeUnavailableAsync(expect, method) {
const error = await expectMethodToThrowAsync(method);
expect(error instanceof UnavailabilityError).toBeTruthy();
}
export async function expectMethodToThrowAsync(method) {
try {
await method();
} catch (error) {
return error;
}
}