-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathccRecap.spec.js
More file actions
174 lines (164 loc) · 4.77 KB
/
Copy pathccRecap.spec.js
File metadata and controls
174 lines (164 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
let request
let caller
const host = process.env.HOST
beforeEach(() => {
jest.resetModules()
const { app } = require('./index')
const supertest = require('supertest')
caller = require('./caller')
request = supertest(app)
})
describe('POST /ccRecapPrompt', () => {
it('returns the percl commands for the payment info recap menu getdigits including redirect and prompt', async () => {
caller.paymentAmt = 20
caller.ccNum = '341814945428581'
const res = await request
.post('/ccRecapPrompt')
.type('form')
.send({ from: '1' })
expect(res.status).toBe(200)
expect(res.body).toStrictEqual([
{
GetDigits: {
actionUrl: `${host}/ccRecap`,
flushBuffer: true,
maxDigits: 1,
minDigits: 1,
prompts: [
{
Say: {
loop: 1,
text:
'Your payment will be 20 dollars on the card ending in 8581, if thats correct press 1 to confirm if not press 2 to try again'
}
}
]
}
}
])
})
})
describe('POST /ccRecap', () => {
it('returns an error when no menu options are selected', async () => {
const res = await request
.post('/ccRecap')
.type('form')
.send({ digits: '' })
expect(res.status).toBe(200)
expect(res.body).toStrictEqual([
{
Say: {
loop: 1,
text: 'Error'
}
},
{
Redirect: {
actionUrl: `${host}/ccRecapPrompt`
}
}
])
})
it('returns transfer to operator if max err limit reached', async () => {
for (let i = 0; i < 3; i++) {
await request
.post('/ccRecap')
.type('form')
.send({ digits: '' })
}
const res = await request
.post('/ccRecap')
.type('form')
.send({ digits: '' })
expect(res.status).toBe(200)
expect(res.body).toStrictEqual([
{
Say: {
loop: 1,
text: 'Please wait while we connect you to an operator'
}
},
{
Pause: {
length: 100
}
},
{
Redirect: {
actionUrl: `${host}/transfer`
}
}
])
})
it('returns transfer to operator if max retry limit reached', async () => {
for (let i = 0; i < 2; i++) {
await request
.post('/ccRecap')
.type('form')
.send({ digits: '2' })
}
const res = await request
.post('/ccRecap')
.type('form')
.send({ digits: '2' })
expect(res.status).toBe(200)
expect(res.body).toStrictEqual([
{
Say: {
loop: 1,
text: 'Please wait while we connect you to an operator'
}
},
{
Pause: {
length: 100
}
},
{
Redirect: {
actionUrl: `${host}/transfer`
}
}
])
})
it('returns redirect to /ccProcess on input of number 1', async () => {
const res = await request
.post('/ccRecap')
.type('form')
.send({ digits: '1' })
expect(res.status).toBe(200)
expect(res.body).toStrictEqual([
{
Say: {
loop: 1,
text: 'great'
}
},
{
Redirect: {
actionUrl: `${host}/ccProcess`
}
}
])
})
it('returns redirect to /ccAmountPrompt on input of number 2', async () => {
const res = await request
.post('/ccRecap')
.type('form')
.send({ digits: '2' })
expect(res.status).toBe(200)
expect(res.body).toStrictEqual([
{
Say: {
loop: 1,
text: 'Sorry to make sure your information is correct lets start again'
}
},
{
Redirect: {
actionUrl: `${host}/ccAmountPrompt`
}
}
])
})
})