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

Merging 2.3.2 into 2.4.0 #2144

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const MediumPromo = ({ customFields }) => {
return null;
}

const hasAuthors = showByline ? content?.credits?.by && content?.credits?.by.length : null;
const hasAuthors = showByline ? content?.credits?.by && content?.credits?.by?.length : null;
const contentDescription = showDescription ? content?.description?.basic : null;
const contentHeading = showHeadline ? content?.headlines?.basic : null;
const contentUrl = content?.websites?.[arcSite]?.website_url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ const ExtraLarge = (props) => {
const contentHeading = showHeadlineXL ? element?.headlines?.basic : null;
const contentUrl = element?.websites?.[arcSite]?.website_url;
const embedMarkup = playVideoInPlaceXL && getVideoFromANS(element);
const hasAuthors = showBylineXL && element?.credits?.by.length > 0;
const contentAuthors =
showBylineXL && element?.credits?.by?.length > 0
? formatAuthors(element.credits.by, phrases.t("global.and-text"))
: null;
const ansImage = getImageFromANS(element);
const imageParams =
element && ansImage
Expand All @@ -107,12 +110,12 @@ const ExtraLarge = (props) => {
contentHeading ||
showImageXL ||
contentDescription ||
hasAuthors ||
contentAuthors ||
hasDate ? (
<>
<article className={BLOCK_CLASS_NAME}>
{hasOverline ? <Overline href={overlineUrl}>{overlineText}</Overline> : null}
{contentHeading || showImageXL || contentDescription || hasAuthors || hasDate ? (
{contentHeading || showImageXL || contentDescription || contentAuthors || hasDate ? (
<Stack>
{contentHeading ? (
<HeadingSection>
Expand Down Expand Up @@ -140,13 +143,13 @@ const ExtraLarge = (props) => {
</MediaItem>
) : null}
{contentDescription ? <Paragraph>{contentDescription}</Paragraph> : null}
{hasAuthors || hasDate ? (
{contentAuthors || hasDate ? (
<Attribution>
<Join separator={Separator}>
{hasAuthors ? (
{contentAuthors ? (
<Join separator={() => " "}>
{phrases.t("global.by-text")}
{formatAuthors(element?.credits?.by, phrases.t("global.and-text"))}
{contentAuthors}
</Join>
) : null}
{hasDate ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import '@testing-library/jest-dom'
import mockData from "../../../mock-data";

import ExtraLarge from "./extra-large";
Expand All @@ -14,23 +15,23 @@ describe("the extra large promo feature", () => {
it("should return null if no show flag is true", () => {
const config = {};
const { container } = render(<ExtraLarge element={mockData} customFields={config} />);
expect(container.firstChild).toBeNull();
expect(container).toBeEmptyDOMElement();
});

it("should return an overline if showOverline is true", () => {
const config = {
showOverlineXL: true,
};
render(<ExtraLarge element={mockData} customFields={config} />);
expect(screen.queryByRole("link", { name: "Premium" })).not.toBeNull();
expect(screen.getByRole("link", { name: "Premium" })).not.toBeNull();
});

it("should return a headline if showHeadline is true", () => {
const config = {
showHeadlineXL: true,
};
render(<ExtraLarge element={mockData} customFields={config} />);
expect(screen.queryByRole("heading", { name: config.headline })).not.toBeNull();
expect(screen.getByRole("heading", { name: config.headline })).not.toBeNull();
});

it("should return a image if showImage is true", () => {
Expand All @@ -39,7 +40,7 @@ describe("the extra large promo feature", () => {
showImageXL: true,
};
render(<ExtraLarge element={mockData} customFields={config} />);
expect(screen.queryByRole("img", { name: config.headline })).not.toBeNull();
expect(screen.getByRole("img", { name: config.headline })).not.toBeNull();
});

it("should return a fallback image if showImage is true and imageUrl is not valid", () => {
Expand All @@ -48,7 +49,7 @@ describe("the extra large promo feature", () => {
showImageXL: true,
};
render(<ExtraLarge element={mockData} customFields={config} />);
expect(screen.queryByRole("img", { name: config.headline })).not.toBeNull();
expect(screen.getByRole("img", { name: config.headline })).not.toBeNull();
});

it("should return a description if showDescription is true", () => {
Expand All @@ -57,17 +58,17 @@ describe("the extra large promo feature", () => {
};
render(<ExtraLarge element={mockData} customFields={config} />);
expect(
screen.queryByText("Why does August seem hotter? Maybe it comes from weariness.")
screen.getByText("Why does August seem hotter? Maybe it comes from weariness.")
).not.toBeNull();
});

it("should return a byline if showByline is true", () => {
const config = {
showBylineXL: true,
};
const { getByText } = render(<ExtraLarge element={mockData} customFields={config} />);
render(<ExtraLarge element={mockData} customFields={config} />);
expect(
getByText("global.by-text Example Author1, Example Author2, global.and-text Example Author3")
screen.getByText("global.by-text Example Author1, Example Author2, global.and-text Example Author3")
).not.toBeNull();
});

Expand All @@ -76,7 +77,7 @@ describe("the extra large promo feature", () => {
showDateXL: true,
};
render(<ExtraLarge element={mockData} customFields={config} />);
expect(screen.queryByText("January 30, 2020", { exact: false })).not.toBeNull();
expect(screen.getByText("January 30, 2020", { exact: false })).not.toBeNull();
});

it("should returned a sponsored overline if it's sponsored content", () => {
Expand All @@ -89,7 +90,7 @@ describe("the extra large promo feature", () => {
showOverlineXL: true,
};
render(<ExtraLarge element={modifiedData} customFields={config} />);
expect(screen.queryByText("global.sponsored-content")).not.toBeNull();
expect(screen.getByText("global.sponsored-content")).not.toBeNull();
});

it("should return a video if playVideoInPlace is true and video content available", () => {
Expand All @@ -106,6 +107,6 @@ describe("the extra large promo feature", () => {
showImageXL: true,
};
render(<ExtraLarge element={modifiedData} customFields={config} />);
expect(screen.queryByText("video embed")).not.toBeNull();
expect(screen.getByText("video embed")).not.toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Medium = (props) => {

const showBottomBorder = typeof showBottomBorderMD === "undefined" ? true : showBottomBorderMD;

const hasAuthors = showBylineMD ? element?.credits?.by && element?.credits?.by.length : null;
const hasAuthors = showBylineMD ? element?.credits?.by && element?.credits?.by?.length : null;
const contentDescription = showDescriptionMD ? element?.description?.basic : null;
const contentHeading = showHeadlineMD ? element?.headlines?.basic : null;
const contentUrl = element?.websites?.[arcSite]?.website_url;
Expand Down
Loading
Loading