File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
handlers/promotions-lambdas Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ const transformPromo = (oldPromo: OldPromo): Promo[] => {
6363 promo . description = oldPromo . description ;
6464 }
6565
66- if ( oldPromo . landingPage ) {
66+ if ( oldPromo . landingPage ?. title ) {
6767 promo . landingPage = {
6868 title : oldPromo . landingPage . title ,
6969 description : oldPromo . landingPage . description ,
Original file line number Diff line number Diff line change @@ -215,4 +215,32 @@ describe('promoSync handler', () => {
215215
216216 expect ( mockedWriteToDynamoDb ) . not . toHaveBeenCalled ( ) ;
217217 } ) ;
218+
219+ it ( 'should not include landingPage when title is undefined' , async ( ) => {
220+ const imageWithoutLandingPageTitle : Record < string , AttributeValue > = {
221+ ...validNewImage ,
222+ landingPage : {
223+ M : {
224+ type : { S : 'supporterPlus' } ,
225+ } ,
226+ } ,
227+ } ;
228+
229+ const record : DynamoDBRecord = {
230+ eventName : 'INSERT' ,
231+ dynamodb : {
232+ NewImage : imageWithoutLandingPageTitle ,
233+ SequenceNumber : '123' ,
234+ } ,
235+ } as DynamoDBRecord ;
236+
237+ await handler ( createEvent ( [ record ] ) ) ;
238+
239+ expect ( mockedWriteToDynamoDb ) . toHaveBeenCalledTimes ( 2 ) ;
240+
241+ const calls = mockedWriteToDynamoDb . mock . calls as Array < [ object , string ] > ;
242+ calls . forEach ( ( [ item ] ) => {
243+ expect ( item ) . not . toHaveProperty ( 'landingPage' ) ;
244+ } ) ;
245+ } ) ;
218246} ) ;
You can’t perform that action at this time.
0 commit comments