/
SMS.js
46 lines (39 loc) · 1.46 KB
/
SMS.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
import * as SMS from 'expo-sms';
import { Platform } from 'react-native';
import { isInteractive } from '../utils/Environment';
import {
testSMSComposeWithSingleImageAttachment,
testSMSComposeWithAudioAttachment,
testSMSComposeWithTwoImageAttachments,
} from './SMSCommon';
export const name = 'SMS';
export function test({ describe, it, expect }) {
if (!isInteractive()) {
describe(`sendSMSAsync()`, () => {
it(`opens an SMS composer`, async () => {
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. Only first one is used.`, async () => {
await testSMSComposeWithTwoImageAttachments(expect);
});
it(`opens an SMS composer with audio attachment`, async () => {
await testSMSComposeWithAudioAttachment(expect);
});
});
}
describe(`isAvailableAsync()`, () => {
if (Platform.OS === 'android' && isInteractive()) {
// TODO(Bacon): Not sure if this works in an emulator or not
it(`has a telephony radio with data communication support`, async () => {
expect(await SMS.isAvailableAsync()).toBe(true);
});
} else {
it(`is not supported on ${Platform.OS}`, async () => {
expect(await SMS.isAvailableAsync()).toBe(false);
});
}
});
}