-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update tests to remove migrated functions
- Loading branch information
Showing
1 changed file
with
1 addition
and
55 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,12 +1,11 @@ | ||
import { ObjectId } from 'bson' | ||
import { okAsync } from 'neverthrow' | ||
import Twilio from 'twilio' | ||
|
||
import { ISms } from 'src/app/config/features/sms.config' | ||
|
||
import { createSmsFactory } from '../sms.factory' | ||
import * as SmsService from '../sms.service' | ||
import { BounceNotificationSmsParams, TwilioConfig } from '../sms.types' | ||
import { TwilioConfig } from '../sms.types' | ||
|
||
// This is hoisted and thus a const cannot be passed in. | ||
jest.mock('twilio', () => | ||
|
@@ -24,15 +23,6 @@ const MOCKED_TWILIO = { | |
mocked: 'this is mocked', | ||
} as unknown as Twilio.Twilio | ||
|
||
const MOCK_BOUNCE_SMS_PARAMS: BounceNotificationSmsParams = { | ||
adminEmail: '[email protected]', | ||
adminId: new ObjectId().toHexString(), | ||
formId: new ObjectId().toHexString(), | ||
formTitle: 'mock form title', | ||
recipient: '+6581234567', | ||
recipientEmail: '[email protected]', | ||
} | ||
|
||
describe('sms.factory', () => { | ||
beforeEach(() => jest.clearAllMocks()) | ||
|
||
|
@@ -49,28 +39,6 @@ describe('sms.factory', () => { | |
} | ||
const SmsFactory = createSmsFactory(MOCK_SMS_FEATURE) | ||
|
||
it('should call SmsService counterpart when invoking sendAdminContactOtp', async () => { | ||
// Arrange | ||
MockSmsService.sendAdminContactOtp.mockReturnValueOnce(okAsync(true)) | ||
|
||
const mockArguments: Parameters<typeof SmsFactory.sendAdminContactOtp> = [ | ||
'mockRecipient', | ||
'mockOtp', | ||
'mockFormId', | ||
'mockSenderIp', | ||
] | ||
|
||
// Act | ||
await SmsFactory.sendAdminContactOtp(...mockArguments) | ||
|
||
// Assert | ||
expect(MockSmsService.sendAdminContactOtp).toHaveBeenCalledTimes(1) | ||
expect(MockSmsService.sendAdminContactOtp).toHaveBeenCalledWith( | ||
...mockArguments, | ||
expectedTwilioConfig, | ||
) | ||
}) | ||
|
||
it('should call SmsService counterpart when invoking sendVerificationOtp', async () => { | ||
// Arrange | ||
MockSmsService.sendVerificationOtp.mockReturnValue(okAsync(true)) | ||
|
@@ -93,26 +61,4 @@ describe('sms.factory', () => { | |
expectedTwilioConfig, | ||
) | ||
}) | ||
|
||
it('should call SmsService when sendFormDeactivatedSms is called', async () => { | ||
MockSmsService.sendFormDeactivatedSms.mockReturnValue(okAsync(true)) | ||
|
||
await SmsFactory.sendFormDeactivatedSms(MOCK_BOUNCE_SMS_PARAMS) | ||
|
||
expect(MockSmsService.sendFormDeactivatedSms).toHaveBeenCalledWith( | ||
MOCK_BOUNCE_SMS_PARAMS, | ||
expectedTwilioConfig, | ||
) | ||
}) | ||
|
||
it('should call SmsService when sendBouncedSubmissionSms is called', async () => { | ||
MockSmsService.sendBouncedSubmissionSms.mockReturnValue(okAsync(true)) | ||
|
||
await SmsFactory.sendBouncedSubmissionSms(MOCK_BOUNCE_SMS_PARAMS) | ||
|
||
expect(MockSmsService.sendBouncedSubmissionSms).toHaveBeenCalledWith( | ||
MOCK_BOUNCE_SMS_PARAMS, | ||
expectedTwilioConfig, | ||
) | ||
}) | ||
}) |