File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 11export * from "./addParticipant.util" ;
22export * from "./createConversation.util" ;
33export * from "./deleteConversation.util" ;
4- export * from "./listParticipantConversations.util"
4+ export * from "./listParticipantConversations.util" ;
5+ export * from "./getConversationByAddressPair.util" ;
Original file line number Diff line number Diff line change 1+ import { getConversationByAddressPair } from "../../src/utils" ;
2+ import client from '../../src/twilioClient' ;
3+ import { ParticipantConversationInstance } from 'twilio/lib/rest/conversations/v1/participantConversation' ;
4+
5+ jest . mock ( '../../src/twilioClient' )
6+ let mockedClient = jest . mocked ( client , true )
7+
8+ describe ( 'GetConversationByAddressPair util' , ( ) => {
9+ beforeEach ( ( ) => {
10+ jest . resetAllMocks ( )
11+ } )
12+
13+ it ( 'it gets Conversation by address pair' , async ( ) => {
14+ const mockParticipants = [ {
15+ conversationState : "closed" ,
16+ conversationSid : "myConversationSid" ,
17+ participantMessagingBinding : {
18+ proxy_address : "+5678"
19+ }
20+ } ]
21+
22+ const createSpy = jest . fn ( ( options ) => { return mockParticipants } )
23+ mockedClient [ 'conversations' ] = {
24+ v1 :{
25+ participantConversations : {
26+ list : ( options ) => createSpy ( options )
27+ }
28+ }
29+ } as any
30+
31+ const result = await getConversationByAddressPair ( "+1234" , "+5678" ) ;
32+ expect ( createSpy ) . toBeCalledWith ( { "address" :"+1234" } ) ;
33+ expect ( result ) . not . toBeNull ( ) ;
34+ // ToDo: add proper mocked response with ParticipantConversationInstance
35+ } )
36+ } )
37+
You can’t perform that action at this time.
0 commit comments