forked from expo/expo
/
SMS.ios.js
54 lines (47 loc) · 1.68 KB
/
SMS.ios.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
import Constants from 'expo-constants';
import * as SMS from 'expo-sms';
import { expectMethodToThrowAsync } from '../TestUtils';
import { isInteractive } from '../utils/Environment';
import {
testSMSComposeWithSingleImageAttachment,
testSMSComposeWithTwoImageAttachments,
testSMSComposeWithAudioAttachment,
} from './SMSCommon';
export const name = 'SMS';
export function test({ describe, it, expect }) {
describe(`sendSMSAsync()`, () => {
if (Constants.isDevice) {
if (isInteractive()) {
it(`opens an SMS composer`, async () => {
// TODO: Bacon: Build an API to close the UI Controller
await SMS.sendSMSAsync(['0123456789', '9876543210'], 'test');
});
it(`opens an SMS composer with single image attachment`, async () => {
await testSMSComposeWithSingleImageAttachment(expect);
});
it(`opens an SMS composer with two image attachments`, async () => {
await testSMSComposeWithTwoImageAttachments(expect);
});
it(`opens an SMS composer with audio attachment`, async () => {
await testSMSComposeWithAudioAttachment(expect);
});
}
} else {
it(`is unavailable`, async () => {
const error = await expectMethodToThrowAsync(SMS.sendSMSAsync);
expect(error.code).toBe('E_SMS_UNAVAILABLE');
});
}
});
describe(`isAvailableAsync()`, () => {
if (Constants.isDevice) {
it(`has access to iOS SMS API`, async () => {
expect(await SMS.isAvailableAsync()).toBe(true);
});
} else {
it(`cannot be used in the iOS simulator`, async () => {
expect(await SMS.isAvailableAsync()).toBe(false);
});
}
});
}