From 4c355dc3b4ba4ea37f941b0b1ddba80aded1a6cf Mon Sep 17 00:00:00 2001 From: Thorben Primke Date: Thu, 23 Apr 2020 11:00:51 -0700 Subject: [PATCH] Updates And Adds Jest Tests For expo-sms --- packages/expo-sms/src/__tests__/SMS-test.ts | 25 +++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/expo-sms/src/__tests__/SMS-test.ts b/packages/expo-sms/src/__tests__/SMS-test.ts index 888b998d77ddb..d9e865f4618e1 100644 --- a/packages/expo-sms/src/__tests__/SMS-test.ts +++ b/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); });