/* eslint-disable @typescript-eslint/no-unused-vars */ import TwilioSMSSenderClient from './twilioSmsSender.client'; import { MessageInstance } from 'twilio/lib/rest/api/v2010/account/message'; jest.mock('twilio', () => { const actualModule = jest.requireActual('twilio'); class Twilio { messages = { create: ({ from, to, body, }: { from: string; to: string; body: string; }): Promise => Promise.resolve({ to } as MessageInstance), }; } return { ...actualModule, Twilio, }; }); jest.mock('../../utils/constants', () => ({ USERNAME: 'qrvey', PASSWORD: '123456', FROM: '+123456789', })); describe('TwilioSMSSender tests.', () => { beforeEach(() => { jest.clearAllMocks(); jest.resetAllMocks(); }); test('Should response with sent messages.', async () => { const smsSender = new TwilioSMSSenderClient(); const result = await smsSender.send( ['+1234567890', '+9876543210'], 'Hello world', ); expect(result).toMatchObject({ sent: [{ phone: '+1234567890' }, { phone: '+9876543210' }], }); }); });