File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import request from 'supertest'
2+ import * as InboundCallService from '../../src/services/inboundCall.service'
3+ import { app } from '../../src/app/app'
4+ import VoiceResponse from 'twilio/lib/twiml/VoiceResponse'
5+
6+ describe ( 'inbound call controller' , ( ) => {
7+ jest . setTimeout ( 3600000 )
8+
9+ // Test parameters
10+ const fromNumber = '+1001'
11+ const toNumber = '+1002'
12+ const twimlResponse = new VoiceResponse ( )
13+ const dial = twimlResponse . dial ( ) ;
14+ dial . conference ( 'Room1234' ) ;
15+
16+ it ( 'should generate twiml' , async ( ) => {
17+ const generateTwimlSpy = jest
18+ . spyOn ( InboundCallService , 'generateTwiml' )
19+ . mockResolvedValue ( twimlResponse )
20+
21+ const res = await request ( app )
22+ . post ( '/inbound-call' )
23+ . set ( 'content-type' , 'application/json' )
24+ // .set('Authorization', process.env.AUTH_HEADER)
25+ . send ( {
26+ From : fromNumber ,
27+ Called : toNumber
28+ } )
29+
30+ expect ( res . status ) . toEqual ( 200 )
31+ expect ( res . text ) . toEqual ( '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference>Room1234</Conference></Dial></Response>' )
32+ expect ( generateTwimlSpy ) . toBeCalledWith ( fromNumber , toNumber )
33+ } )
34+ } )
You can’t perform that action at this time.
0 commit comments