Skip to content

Commit

Permalink
Updates And Adds Jest Tests For expo-sms
Browse files Browse the repository at this point in the history
  • Loading branch information
thorbenprimke committed Apr 23, 2020
1 parent 403fbbc commit 4c355dc
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions packages/expo-sms/src/__tests__/SMS-test.ts
@@ -1,13 +1,34 @@
import { NativeModulesProxy } from '@unimodules/core';

import * as SMS from '../SMS';
import { MMSAttachmentType } from '../SMS.types';

it(`normalizes one phone number into an array`, async () => {
const { ExpoSMS } = NativeModulesProxy;

await SMS.sendSMSAsync('0123456789', 'test');
expect(ExpoSMS.sendSMSAsync).toHaveBeenLastCalledWith(['0123456789'], 'test');
expect(ExpoSMS.sendSMSAsync).toHaveBeenLastCalledWith(['0123456789'], 'test', undefined);

await SMS.sendSMSAsync(['0123456789', '9876543210'], 'test');
expect(ExpoSMS.sendSMSAsync).toHaveBeenLastCalledWith(['0123456789', '9876543210'], 'test');
expect(ExpoSMS.sendSMSAsync).toHaveBeenLastCalledWith(
['0123456789', '9876543210'],
'test',
undefined
);
});

it(`passes attachmentData parameter to native`, async () => {
const { ExpoSMS } = NativeModulesProxy;

await SMS.sendSMSAsync('0123456789', 'test');
expect(ExpoSMS.sendSMSAsync).toHaveBeenLastCalledWith(['0123456789'], 'test', undefined);

const attachmentData = {
contentUri: 'path/myfile.png',
iOSFilename: 'myfile.png',
iOSType: 'public.png',
androidType: 'image/png',
} as MMSAttachmentType;
await SMS.sendSMSAsync('0123456789', 'test', attachmentData);
expect(ExpoSMS.sendSMSAsync).toHaveBeenLastCalledWith(['0123456789'], 'test', attachmentData);
});

0 comments on commit 4c355dc

Please sign in to comment.