From faba5b5f0b0223ad019c41b947838d7f79cec2b4 Mon Sep 17 00:00:00 2001 From: blakeganderson <85515364+blakeganderson@users.noreply.github.com> Date: Thu, 30 May 2024 17:33:23 -0400 Subject: [PATCH] updated cardlist block to respect offsetOverride --- blocks/card-list-block/features/card-list/default.jsx | 10 +++++----- .../features/card-list/default.test.jsx | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/blocks/card-list-block/features/card-list/default.jsx b/blocks/card-list-block/features/card-list/default.jsx index cf9ce369d3..0eae4bd4c2 100644 --- a/blocks/card-list-block/features/card-list/default.jsx +++ b/blocks/card-list-block/features/card-list/default.jsx @@ -142,7 +142,7 @@ const CardListItems = (props) => { contentItems = contentItems.slice(0, displayAmount); } - const sourceContent = contentElements[0]; + const sourceContent = contentElements[offsetOverride]; const displayDate = localizeDateTime(sourceContent.display_date, dateTimeFormat, language, timeZone); @@ -183,10 +183,10 @@ const CardListItems = (props) => { }, responsiveImages: [377, 754, 1508], width: 377, - } + } : { src: targetFallbackImage, - }; + }; return contentItems.length > 0 ? ( @@ -243,10 +243,10 @@ const CardListItems = (props) => { }, responsiveImages: [105, 210, 420], width: 105, - } + } : { src: targetFallbackImage, - }; + }; return ( { const customFields = { listContentConfig, offsetOverride: 1 }; render(); - + expect(screen.queryByText("Article with only promo_items.basic")).toBeNull(); expect(screen.getByText("2nd Story Title")).not.toBeNull(); + expect(screen.getByText("John M Doe")).not.toBeNull(); }); it("should render a list of stories only for the arcSite", () => { @@ -152,7 +153,7 @@ describe("Card list", () => { }; const title = "Test Title"; const customFields = { listContentConfig, title }; - + useContent.mockReturnValueOnce(oneListItem); render(); };