File tree Expand file tree Collapse file tree 4 files changed +38
-2
lines changed
modules/baseMessageModule Expand file tree Collapse file tree 4 files changed +38
-2
lines changed File renamed without changes.
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import nock from 'nock';
2
2
3
3
import { API_URL } from '../../constants' ;
4
4
import { SMSAPI } from '../../smsapi' ;
5
+ import { MessageErrorResponse } from '../../types' ;
5
6
6
7
const smsapi = new SMSAPI ( 'someToken' ) ;
7
8
@@ -96,4 +97,39 @@ describe('Base message module', () => {
96
97
// then
97
98
expect ( req . isDone ( ) ) . toBeTruthy ( ) ;
98
99
} ) ;
100
+
101
+ it ( 'should throw error when sms.do returns one' , async ( ) => {
102
+ // given
103
+ const invalidNumber = '500000xxx' ;
104
+ const message = 'someMessage' ;
105
+ const errorResponse : MessageErrorResponse = {
106
+ error : 13 ,
107
+ message : 'No correct phone numbers' ,
108
+ } ;
109
+
110
+ const date = new Date ( ) ;
111
+
112
+ const req = nock ( API_URL )
113
+ . post ( '/sms.do' , {
114
+ date : date . toISOString ( ) ,
115
+ date_validate : true ,
116
+ details : true ,
117
+ encoding : 'utf-8' ,
118
+ format : 'json' ,
119
+ message,
120
+ to : invalidNumber ,
121
+ } )
122
+ . reply ( 200 , errorResponse ) ;
123
+
124
+ // when
125
+ try {
126
+ await smsapi . sms . sendSms ( invalidNumber , message , {
127
+ date,
128
+ } ) ;
129
+ } catch ( error ) {
130
+ expect ( req . isDone ( ) ) . toBeTruthy ( ) ;
131
+
132
+ expect ( error . data ) . toEqual ( errorResponse ) ;
133
+ }
134
+ } ) ;
99
135
} ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {
12
12
MessageError ,
13
13
MessageErrorResponse ,
14
14
isMessageErrorResponseData ,
15
- } from '../../errors/MessageResponseError ' ;
15
+ } from '../../errors/MessageError ' ;
16
16
17
17
import {
18
18
MessageContent ,
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import { SubuserCredentials } from '../modules/subusers/types/SubuserCredentials
15
15
import { SubuserPoints } from '../modules/subusers/types/SubuserPoints' ;
16
16
import { Template } from '../modules/templates/types/Template' ;
17
17
import { UpdateSubuser } from '../modules/subusers/types/UpdateSubuser' ;
18
- import { MessageErrorResponse } from '../errors/MessageResponseError ' ;
18
+ import { MessageErrorResponse } from '../errors/MessageError ' ;
19
19
20
20
import { MessageStatus } from './MessageStatus' ;
21
21
import { MessageResponse } from './MessageResponse' ;
You can’t perform that action at this time.
0 commit comments