1- import { ConversationInstance } from 'twilio/lib/rest/conversations/v1/conversation'
2- import { CreateConversation } from " ../../src/utils/createConversation.util"
1+ import { createConversation } from "../../src/utils" ;
2+ import client from ' ../../src/twilioClient'
33
4- describe ( 'conversations service' , ( ) => {
5- const mockValue = { } as ConversationInstance
6- const testInstance = new CreateConversation
4+ jest . mock ( '../../src/twilioClient' )
5+ let mockedClient = jest . mocked ( client , true )
6+
7+ describe ( 'createConversation util' , ( ) => {
8+ beforeEach ( ( ) => {
9+ jest . resetAllMocks ( )
10+ } )
711
8- let spy = jest . spyOn ( testInstance , 'callCreate' ) . mockResolvedValue ( mockValue )
12+ it ( 'it creates conversation with options passed' , async ( ) => {
13+ const createSpy = jest . fn ( ( options ) => { } )
14+ mockedClient [ 'conversations' ] = {
15+ conversations : {
16+ create : ( options ) => createSpy ( options )
17+ }
18+ } as any
919
10- test ( "It creates a conversation", async ( ) => {
11- await testInstance . createConversation ( { friendlyName : 'test' , addresses : [ '1' , '2' ] } )
12- expect ( spy ) . toBeCalled ( )
20+ createConversation ( { friendlyName : "my conversation", addresses : [ '1' , '2' ] } )
21+
22+ expect ( createSpy ) . toBeCalledWith ( { friendlyName : "my conversation" , addresses : [ '1' , '2' ] } )
1323 } )
14- } )
1524
25+ it ( 'calls quit if error is not a 429 retry' , async ( ) => {
26+
27+ } )
28+ } )
0 commit comments