Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated cardlist block to respect offsetOverride #2152

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions blocks/card-list-block/features/card-list/default.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -183,10 +183,10 @@ const CardListItems = (props) => {
},
responsiveImages: [377, 754, 1508],
width: 377,
}
}
: {
src: targetFallbackImage,
};
};

return contentItems.length > 0 ? (
<HeadingSection>
Expand Down Expand Up @@ -243,10 +243,10 @@ const CardListItems = (props) => {
},
responsiveImages: [105, 210, 420],
width: 105,
}
}
: {
src: targetFallbackImage,
};
};
return (
<Stack
as="article"
Expand Down
5 changes: 3 additions & 2 deletions blocks/card-list-block/features/card-list/default.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ describe("Card list", () => {
const customFields = { listContentConfig, offsetOverride: 1 };

render(<CardList customFields={customFields} />);

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", () => {
Expand Down Expand Up @@ -152,7 +153,7 @@ describe("Card list", () => {
};
const title = "Test Title";
const customFields = { listContentConfig, title };

useContent.mockReturnValueOnce(oneListItem);
render(<CardList customFields={customFields} />);
};
Expand Down
Loading