/* eslint-disable @typescript-eslint/no-unused-vars */ import { SmsClient, SmsSendResult } from '@azure/communication-sms'; import AzureSMSSenderClient from './azureSmsSender.client'; jest.mock('@azure/communication-sms', () => { const actualModule = jest.requireActual('@azure/communication-sms'); class SmsClient { send({ from, to, message, }: { from: string; to: string[]; message: string; }): Promise { return Promise.resolve( to.map((phone) => ({ to: phone })) as SmsSendResult[], ); } } return { ...actualModule, SmsClient, }; }); jest.mock('../../utils/constants', () => ({ FROM: '+123456789', USERNAME: 'qrvey', PASSWORD: '123456', })); describe('AzureSMSSender tests.', () => { beforeEach(() => { jest.clearAllMocks(); jest.resetAllMocks(); }); test('Should call send method.', async () => { const smsSender = new AzureSMSSenderClient(); const clientSend = jest.spyOn(SmsClient.prototype, 'send'); await smsSender.send(['+1234567890', '+9876543210'], 'Hello world'); expect(clientSend).toHaveBeenCalledTimes(1); }); });