@@ -184,6 +184,22 @@ describe('#buildWhatsAppProcessedParams', () => {
184184 buildWhatsAppProcessedParams ( whatsAppTemplate ( { components : [ ] } ) )
185185 ) . toEqual ( { } ) ;
186186 } ) ;
187+
188+ it ( 'builds component-scoped parameters for text header and body variables' , ( ) => {
189+ const params = buildWhatsAppProcessedParams (
190+ whatsAppTemplate ( {
191+ components : [
192+ { type : 'HEADER' , format : 'TEXT' , text : 'Welcome {{1}}' } ,
193+ { type : 'BODY' , text : 'Hello {{1}}, your manager is {{2}}.' } ,
194+ ] ,
195+ } )
196+ ) ;
197+
198+ expect ( params ) . toEqual ( {
199+ header : { '1' : '' } ,
200+ body : { '1' : '' , '2' : '' } ,
201+ } ) ;
202+ } ) ;
187203} ) ;
188204
189205describe ( '#isWhatsAppComplete' , ( ) => {
@@ -212,6 +228,23 @@ describe('#isWhatsAppComplete', () => {
212228 true
213229 ) ;
214230 } ) ;
231+
232+ it ( 'requires text header and body variables' , ( ) => {
233+ const textHeader = whatsAppTemplate ( {
234+ components : [
235+ { type : 'HEADER' , format : 'TEXT' , text : 'Welcome {{1}}' } ,
236+ { type : 'BODY' , text : 'Hello {{1}}, your manager is {{2}}.' } ,
237+ ] ,
238+ } ) ;
239+ const params = buildWhatsAppProcessedParams ( textHeader ) ;
240+
241+ params . body ! [ '1' ] = 'Ahmad' ;
242+ params . body ! [ '2' ] = 'Furqan' ;
243+ expect ( isWhatsAppComplete ( textHeader , params ) ) . toBe ( false ) ;
244+
245+ params . header ! [ '1' ] = 'Ahmad' ;
246+ expect ( isWhatsAppComplete ( textHeader , params ) ) . toBe ( true ) ;
247+ } ) ;
215248} ) ;
216249
217250describe ( 'twilio helpers' , ( ) => {
0 commit comments