From f2210f45737a90ed29fe0c27c10fb735f4328b45 Mon Sep 17 00:00:00 2001 From: Amogh S Date: Fri, 3 Jul 2020 11:45:22 +0530 Subject: [PATCH] fix: rename text story to generic story (#223) Co-authored-by: Amogh Sahasrabhojanee --- src/helpers/ampify-story/ampify-story.tsx | 4 ++-- .../__snapshots__/generic-story.test.tsx.snap} | 2 +- .../generic-story/generic-story.stories.tsx | 15 +++++++++++++++ .../generic-story.test.tsx} | 16 ++++++++-------- .../generic-story.tsx} | 7 +++---- .../{text-story => generic-story}/types.ts | 2 +- src/templates/index.ts | 4 ++-- src/templates/text-story/text-story.stories.tsx | 15 --------------- 8 files changed, 32 insertions(+), 33 deletions(-) rename src/templates/{text-story/__snapshots__/text-story.test.tsx.snap => generic-story/__snapshots__/generic-story.test.tsx.snap} (99%) create mode 100644 src/templates/generic-story/generic-story.stories.tsx rename src/templates/{text-story/text-story.test.tsx => generic-story/generic-story.test.tsx} (76%) rename src/templates/{text-story/text-story.tsx => generic-story/generic-story.tsx} (94%) rename src/templates/{text-story => generic-story}/types.ts (83%) delete mode 100644 src/templates/text-story/text-story.stories.tsx diff --git a/src/helpers/ampify-story/ampify-story.tsx b/src/helpers/ampify-story/ampify-story.tsx index 34e81838..a25cbdc5 100644 --- a/src/helpers/ampify-story/ampify-story.tsx +++ b/src/helpers/ampify-story/ampify-story.tsx @@ -1,6 +1,6 @@ import { AmpifyStoryTypes } from "./types"; import renderToString from "../render-to-string"; -import { TextStory } from "../../templates/text-story/text-story"; +import { GenericStory } from "../../templates"; import get from "lodash.get"; import React from "react"; @@ -31,6 +31,6 @@ const getTemplate = ({ story, config, relatedStories, infiniteScrollInlineConfig switch (storyType) { default: - return ; + return ; } }; diff --git a/src/templates/text-story/__snapshots__/text-story.test.tsx.snap b/src/templates/generic-story/__snapshots__/generic-story.test.tsx.snap similarity index 99% rename from src/templates/text-story/__snapshots__/text-story.test.tsx.snap rename to src/templates/generic-story/__snapshots__/generic-story.test.tsx.snap index a34625ed..47c0cca4 100644 --- a/src/templates/text-story/__snapshots__/text-story.test.tsx.snap +++ b/src/templates/generic-story/__snapshots__/generic-story.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`TextStory Template should render 1`] = ` +exports[`GenericStory Template should render 1`] = `
{story()}
) + .add("Story with JS Embeds", () => ( + + )) + .add("Generic Text Story", () => ) + .add("All Elements Story", () => ( + + )); diff --git a/src/templates/text-story/text-story.test.tsx b/src/templates/generic-story/generic-story.test.tsx similarity index 76% rename from src/templates/text-story/text-story.test.tsx rename to src/templates/generic-story/generic-story.test.tsx index 7e7c5f41..e50b467f 100644 --- a/src/templates/text-story/text-story.test.tsx +++ b/src/templates/generic-story/generic-story.test.tsx @@ -1,24 +1,24 @@ import React from "react"; import { shallow } from "enzyme"; -import { TextStory } from "./text-story"; +import { GenericStory } from "./generic-story"; import { RelatedStories } from "../../molecules"; import { InfiniteScroll } from "../../atoms"; import { textStory, config, relatedStories } from "../../__fixtures__"; import cloneDeep from "lodash.clonedeep"; -describe("TextStory Template", () => { +describe("GenericStory Template", () => { it("should render", () => { - const wrapper = shallow(); + const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); }); it("should render related stories component", () => { - const wrapper = shallow(); + const wrapper = shallow(); expect(wrapper.find(RelatedStories).length).toBe(1); }); it("should render infinite scroll component if exists", () => { const modifiedConfig = cloneDeep(config); const wrapper = shallow( - { }); it("should not render infinite scroll component if infinite-scroll-collection-id not passed in ampconfig", () => { const modifiedConfig = cloneDeep(config); - const wrapper = shallow(); + const wrapper = shallow(); expect(wrapper.find(InfiniteScroll).length).toBe(0); }); it("should call relatedStoriesRender prop when passed to opts", () => { const relatedStoriesRender = jest.fn(); const modifiedConfig = { ...config, opts: { ...config.opts, relatedStoriesRender } }; - const wrapper = shallow(); + const wrapper = shallow(); expect(relatedStoriesRender.mock.calls.length).toBe(1); expect(wrapper.find(RelatedStories).length).toBe(0); }); @@ -43,7 +43,7 @@ describe("TextStory Template", () => { const infiniteScrollRender = jest.fn(); const modifiedConfig = { ...config, opts: { ...config.opts, infiniteScrollRender } }; const wrapper = shallow( - props.theme.spacing.s}; `; const canDisplayBodyAd = (cardIdx) => cardIdx === 0; -const TextStory = ({ story, config, relatedStories, infiniteScrollInlineConfig }: TextStoryTypes) => { + +export const GenericStory = ({ story, config, relatedStories, infiniteScrollInlineConfig }: GenericStoryTypes) => { const footerText = get(config, ["publisherConfig", "publisher-settings", "copyright"], null); const infiniteScrollExists = infiniteScrollInlineConfig && infiniteScrollInlineConfig.length; // should also check if infinite scroll collection exists here let lastComponent =