Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates And Adds Jest Tests For expo-sms
- Loading branch information
1 parent
403fbbc
commit 4c355dc
Showing
1 changed file
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |