Skip to content

Commit 4291ac4

Browse files
committed
Add test to participantsToDial
1 parent 199a36b commit 4291ac4

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

src/utils/participantsToDial.util.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ export const participantsToDial = (participants: Array<ParticipantInstance>, fro
55

66
const output = participants.reduce((result, p) => {
77
if (p.messagingBinding.type === "sms" && p.messagingBinding.address != from) {
8-
console.log(`Adding ${p.messagingBinding.address} to list of numbers to dial.\n`)
9-
10-
result.push({
11-
address: p.messagingBinding.address,
12-
proxyAddress: p.messagingBinding.proxy_address
13-
})
8+
console.log(`Adding ${p.messagingBinding.address} to list of numbers to dial.\n`)
9+
10+
result.push({
11+
address: p.messagingBinding.address,
12+
proxyAddress: p.messagingBinding.proxy_address
13+
})
1414
}
1515

1616
return result;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { participantsToDial } from "../../src/utils"
2+
3+
describe('participantsToDial', () => {
4+
it('only dials SMS type bindings that are not the person calling', async () => {
5+
const participants = [
6+
{
7+
messagingBinding: {
8+
type: 'sms',
9+
address: '+1111111111',
10+
proxy_address: '+0000000000'
11+
}
12+
}, {
13+
messagingBinding: {
14+
type: 'chat',
15+
address: 'chat_client'
16+
}
17+
}, {
18+
messagingBinding: {
19+
type: 'sms',
20+
address: '+2222222222',
21+
proxy_address: '+0000000000'
22+
}
23+
}
24+
] as any
25+
26+
const result = participantsToDial(participants, '+1111111111')
27+
28+
expect(result).toEqual([{"address": "+2222222222", "proxyAddress": "+0000000000"}])
29+
})
30+
})

0 commit comments

Comments
 (0)