@@ -1226,19 +1226,48 @@ describe('questionnaire reducer', () => {
1226
1226
} )
1227
1227
} )
1228
1228
1229
- it ( 'should validate mobileweb message must not be blank if mobileweb mode is on' , ( ) => {
1229
+ it ( 'should validate SMS parts messages must not be blank if "SMS" mode is on and there are SMS parts ' , ( ) => {
1230
1230
const resultState = playActions ( [
1231
1231
actions . fetch ( 1 , 1 ) ,
1232
1232
actions . receive ( questionnaire ) ,
1233
- actions . addMode ( 'mobileweb' ) ,
1234
- actions . changeStepPromptMobileWeb ( '17141bea-a81c-4227-bdda-f5f69188b0e7' , '' )
1233
+ actions . removeMode ( 'ivr' ) ,
1234
+ actions . addLanguage ( 'es' ) ,
1235
+ // Two empty sms parts (empty before and after split separator)
1236
+ actions . changeStepPromptSms ( '17141bea-a81c-4227-bdda-f5f69188b0e7' , `${ smsSplitSeparator } ` ) ,
1237
+ actions . setActiveLanguage ( 'es' ) ,
1238
+ // One empty sms parts (empty after split separator)
1239
+ actions . changeStepPromptSms ( '17141bea-a81c-4227-bdda-f5f69188b0e7' , `Hola!${ smsSplitSeparator } ` ) ,
1235
1240
] )
1236
1241
1237
- expect ( resultState . errors ) . toInclude ( {
1238
- path : "steps[0].prompt['en'].mobileweb" ,
1242
+ const errors = resultState . errors
1243
+ expect ( errors ) . toInclude ( {
1244
+ path : "steps[1].prompt['en'].sms" ,
1239
1245
lang : 'en' ,
1240
- mode : 'mobileweb' ,
1241
- message : [ 'Mobile web prompt must not be blank' ]
1246
+ mode : 'sms' ,
1247
+ message : [ '[0]SMS prompt must not be blank' ]
1248
+ } )
1249
+ expect ( errors ) . toInclude ( {
1250
+ path : "steps[1].prompt['en'].sms" ,
1251
+ lang : 'en' ,
1252
+ mode : 'sms' ,
1253
+ message : [ '[1]SMS prompt must not be blank' ]
1254
+ } )
1255
+
1256
+ expect ( errors ) . toInclude ( {
1257
+ path : "steps[1].prompt['es'].sms" ,
1258
+ lang : 'es' ,
1259
+ mode : 'sms' ,
1260
+ message : [ '[1]SMS prompt must not be blank' ]
1261
+ } )
1262
+
1263
+ expect ( resultState . errorsByPath ) . toInclude ( {
1264
+ "steps[1].prompt['en'].sms" : [ [ '[0]SMS prompt must not be blank' ] , [ '[1]SMS prompt must not be blank' ] ] ,
1265
+ "steps[1].prompt['es'].sms" : [ [ '[1]SMS prompt must not be blank' ] ]
1266
+ } )
1267
+
1268
+ expect ( resultState . errorsByLang ) . toInclude ( {
1269
+ 'en' : true ,
1270
+ 'es' : true ,
1242
1271
} )
1243
1272
} )
1244
1273
@@ -1288,6 +1317,22 @@ describe('questionnaire reducer', () => {
1288
1317
} )
1289
1318
} )
1290
1319
1320
+ it ( 'should validate mobileweb message must not be blank if mobileweb mode is on' , ( ) => {
1321
+ const resultState = playActions ( [
1322
+ actions . fetch ( 1 , 1 ) ,
1323
+ actions . receive ( questionnaire ) ,
1324
+ actions . addMode ( 'mobileweb' ) ,
1325
+ actions . changeStepPromptMobileWeb ( '17141bea-a81c-4227-bdda-f5f69188b0e7' , '' )
1326
+ ] )
1327
+
1328
+ expect ( resultState . errors ) . toInclude ( {
1329
+ path : "steps[0].prompt['en'].mobileweb" ,
1330
+ lang : 'en' ,
1331
+ mode : 'mobileweb' ,
1332
+ message : [ 'Mobile web prompt must not be blank' ]
1333
+ } )
1334
+ } )
1335
+
1291
1336
it ( 'should not include an error if mobile web sms message prompt exceeds the character limit' , ( ) => {
1292
1337
const prompt = 'a' . repeat ( 141 )
1293
1338
0 commit comments