From b66c18df288f1e62744b60456338551b10da55d1 Mon Sep 17 00:00:00 2001 From: Can Ural Date: Fri, 10 Dec 2021 16:09:45 +0200 Subject: [PATCH] Fix news images, add placeholder, update snapshot --- src/components/top-stories/TopStories.jsx | 56 ++++++++++--------- .../__snapshots__/TopStories.test.js.snap | 5 ++ 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/components/top-stories/TopStories.jsx b/src/components/top-stories/TopStories.jsx index 425dbcb..1b95e11 100644 --- a/src/components/top-stories/TopStories.jsx +++ b/src/components/top-stories/TopStories.jsx @@ -3,6 +3,7 @@ import moment from "moment"; import { useSelector } from "utils/react-redux-hooks"; import StoryTopic from "components/story-topic/StoryTopic"; +import placeholder from "assets/newsPlaceholder.png"; import { Date } from "components/story-topic-headers/StoryTopicHeaders.styles"; import { SeeAll } from "components/most-popular/MostPopular.styles"; @@ -16,38 +17,41 @@ import { } from "./TopStories.styles"; const TopStories = () => { - const { story, width } = useSelector((state) => state.news); + const { story } = useSelector((state) => state.news); return (
- {story.slice(0, 3).map((data) => ( - - story - -

- {data.section} -

- - {moment(data.created_date).format("MMM DD, YYYY")} - -
+ {story.slice(0, 3).map((data) => { + const url = data?.multimedia?.[0]?.url; - {data.title} - - {data.abstract.split(" ").slice(0, 20).join(" ")}... - - - Continue Reading - -
- ))} + return ( + + story + +

+ {data.section} +

+ + {moment(data.created_date).format("MMM DD, YYYY")} + +
+ + {data.title} + + {data.abstract.split(" ").slice(0, 20).join(" ")}... + + + Continue Reading + +
+ ); + })}
); diff --git a/src/tests/components/__snapshots__/TopStories.test.js.snap b/src/tests/components/__snapshots__/TopStories.test.js.snap index fcd5cce..4261c84 100644 --- a/src/tests/components/__snapshots__/TopStories.test.js.snap +++ b/src/tests/components/__snapshots__/TopStories.test.js.snap @@ -264,6 +264,11 @@ exports[`Testing TopStories component Should match snapshot 1`] = ` story