Skip to content

Commit af8fa92

Browse files
committed
PR Feedback
1 parent 7c19a64 commit af8fa92

7 files changed

+33
-16
lines changed

tests/utils/addParticipant.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addParticipant } from "../../src/utils";
22
import client from '../../src/twilioClient';
33

4-
import { ParticipantInstance, ParticipantListInstanceCreateOptions } from "twilio/lib/rest/conversations/v1/conversation/participant";
4+
import { ParticipantListInstanceCreateOptions } from "twilio/lib/rest/conversations/v1/conversation/participant";
55

66

77
jest.mock('../../src/twilioClient')
@@ -53,8 +53,9 @@ describe('addParticipant util', () => {
5353
try {
5454
await addParticipant("myConversationSid", mockParticipant );
5555
} catch (e) {
56-
expect(consoleSpy).toHaveBeenCalledWith('Quit without retry');
56+
console.log(e)
5757
}
58+
expect(consoleSpy).toHaveBeenCalledWith('Quit without retry');
5859
})
5960

6061
it('throws error to retry on 429 status code', async () => {
@@ -87,7 +88,9 @@ describe('addParticipant util', () => {
8788
try {
8889
await addParticipant("myConversationSid", mockParticipant, { retries: 0, factor: 1, maxTimeout: 0, minTimeout: 0 });
8990
} catch (e) {
90-
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
91+
console.log(e);
9192
}
93+
94+
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
9295
})
9396
})

tests/utils/createConversation.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ describe('createConversation util', () => {
3737
try {
3838
await createConversation({ friendlyName: "my conversation", addresses: ['1', '2'] });
3939
} catch (e) {
40-
expect(consoleSpy).toHaveBeenCalledWith('Quit without retry');
40+
console.log(e)
4141
}
42+
43+
expect(consoleSpy).toHaveBeenCalledWith('Quit without retry');
4244
})
4345

4446
it('throws error to retry on 429 status code', async () => {
@@ -70,7 +72,9 @@ describe('createConversation util', () => {
7072
{ friendlyName: "my conversation", addresses: ['1', '2']},
7173
{ retries: 0, factor: 1, maxTimeout: 0, minTimeout: 0 });
7274
} catch (e) {
73-
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
75+
console.log(e)
7476
}
77+
78+
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
7579
})
7680
})

tests/utils/deleteConversation.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ describe('deleteConversation util', () => {
5555
try {
5656
await deleteConversation("myConversationSid");
5757
} catch (e) {
58-
expect(consoleSpy).toHaveBeenCalledWith('Quit without retry');
58+
console.log(e)
5959
}
60+
61+
expect(consoleSpy).toHaveBeenCalledWith('Quit without retry');
6062
})
6163

6264
it('retrys if error is 429', async () => {
@@ -93,7 +95,9 @@ describe('deleteConversation util', () => {
9395
try {
9496
await deleteConversation("myConversationSid", { retries: 0, factor: 1, maxTimeout: 0, minTimeout: 0 });
9597
} catch (e) {
96-
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
98+
console.log(e)
9799
}
100+
101+
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
98102
})
99103
})

tests/utils/getConversationByAddressPair.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('GetConversationByAddressPair util', () => {
5757

5858
await expect(getConversationByAddressPair("bad input", "worse input"))
5959
.rejects
60-
.toThrowError('Twilio Proble')
60+
.toThrowError('Error: Twilio Problem')
6161
})
6262

6363
it("should retry if Twilio error is 429", async () => {
@@ -89,8 +89,10 @@ describe('GetConversationByAddressPair util', () => {
8989
try {
9090
await getConversationByAddressPair("+1234", "+5678", { retries: 0, factor: 1, maxTimeout: 0, minTimeout: 0 });
9191
} catch (e) {
92-
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
92+
console.log(e)
9393
}
94+
95+
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
9496
})
9597
})
9698

tests/utils/listConversationParticipants.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('listConversationParticipants', () => {
4444

4545
await expect(listConversationParticipants("CH123"))
4646
.rejects
47-
.toThrowError('Participant List Erro')
47+
.toThrowError('Participant List Error')
4848
})
4949

5050
it('should retry if Twilio client throws a 429 error', async () => {
@@ -78,8 +78,10 @@ describe('listConversationParticipants', () => {
7878

7979
try {
8080
await listConversationParticipants("CH123", { retries: 0, factor: 1, maxTimeout: 0, minTimeout: 0 })
81-
} catch(err) {
82-
expect(consoleSpy).toBeCalledWith('Re-trying on 429 error')
81+
} catch(e) {
82+
console.log(e)
8383
}
84+
85+
expect(consoleSpy).toBeCalledWith('Re-trying on 429 error')
8486
})
8587
})

tests/utils/listParticipantConversations.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { listParticipantConversations } from "../../src/utils";
22
import client from '../../src/twilioClient';
3-
import { ParticipantConversationInstance } from 'twilio/lib/rest/conversations/v1/participantConversation'
43

54
jest.mock('../../src/twilioClient')
65
let mockedClient = jest.mocked(client, true)
@@ -39,8 +38,10 @@ describe('ListParticipantConversations util', () => {
3938
try {
4039
await listParticipantConversations("+1234");
4140
} catch (e) {
42-
expect(consoleSpy).toHaveBeenCalledWith('Quit without retry');
41+
console.log(e)
4342
}
43+
44+
expect(consoleSpy).toHaveBeenCalledWith('Quit without retry');
4445
})
4546

4647

@@ -73,8 +74,10 @@ describe('ListParticipantConversations util', () => {
7374
"+1234",
7475
{ retries: 0, factor: 1, maxTimeout: 0, minTimeout: 0 });
7576
} catch (e) {
76-
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
77+
console.log(e)
7778
}
79+
80+
expect(consoleSpy).toHaveBeenCalledWith('Re-trying on 429 error');
7881
})
7982

8083
})

tests/utils/retryAddParticipant.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ describe('retryParticipantAdd', () => {
3434
mockAddParticipant
3535
.mockRejectedValueOnce(rejectedValue)
3636
.mockResolvedValueOnce(mockParticpantInstance as any)
37-
// .mockResolvedValueOnce(mockParticpantInstance as any)
3837

3938
const result = await retry.retryAddParticipant('CH1234', '+111', ['+222', '+333'])
4039
expect(retrySpy).toBeCalledTimes(1)

0 commit comments

Comments
 (0)