From 0c7aebb1ef0d1c6e0260ae9a1c8cb5fce4eb6867 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 27 Mar 2020 12:17:20 +0100 Subject: [PATCH] fixed storyshot test which renders a DateFromNow without baseDate --- .../src/repos/RepositoryEntry.stories.tsx | 30 ++++++++++--------- .../src/repos/RepositoryEntry.tsx | 13 +++++--- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/scm-ui/ui-components/src/repos/RepositoryEntry.stories.tsx b/scm-ui/ui-components/src/repos/RepositoryEntry.stories.tsx index f8b9994fd0..22979c631b 100644 --- a/scm-ui/ui-components/src/repos/RepositoryEntry.stories.tsx +++ b/scm-ui/ui-components/src/repos/RepositoryEntry.stories.tsx @@ -21,30 +21,29 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -import {storiesOf} from "@storybook/react"; -import React, {FC, ReactNode} from "react"; +import { storiesOf } from "@storybook/react"; +import React, { FC, ReactNode } from "react"; import styled from "styled-components"; import repository from "../__resources__/repository"; // @ts-ignore ignore unknown png import Git from "../__resources__/git-logo.png"; import RepositoryEntry from "./RepositoryEntry"; -import {Binder, BinderContext} from "@scm-manager/ui-extensions"; -import {Repository} from "@scm-manager/ui-types"; +import { Binder, BinderContext } from "@scm-manager/ui-extensions"; +import { Repository } from "@scm-manager/ui-types"; import Image from "../Image"; -import classNames from "classnames"; import Icon from "../Icon"; +const baseDate = "2020-03-26T12:13:42+02:00"; + const Spacing = styled.div` margin: 2rem; `; -const Container: FC = ({children}) => ( - {children} -); +const Container: FC = ({ children }) => {children}; const bindAvatar = (binder: Binder, avatar: string) => { binder.bind("repos.repository-avatar", () => { - return Logo; + return Logo; }); }; @@ -63,18 +62,21 @@ const bindQuickLink = (binder: Binder, extension: ReactNode) => { const withBinder = (binder: Binder, repository: Repository) => { return ( - + ); }; -const QuickLink = ; +const QuickLink = ( + + + +); storiesOf("RepositoryEntry", module) .addDecorator(storyFn => {storyFn()}) .add("Default", () => { - return ; + return ; }) .add("Avatar EP", () => { const binder = new Binder("avatar"); @@ -83,7 +85,7 @@ storiesOf("RepositoryEntry", module) }) .add("Before Title EP", () => { const binder = new Binder("title"); - bindBeforeTitle(binder, ); + bindBeforeTitle(binder, ); return withBinder(binder, repository); }) .add("Quick Link EP", () => { diff --git a/scm-ui/ui-components/src/repos/RepositoryEntry.tsx b/scm-ui/ui-components/src/repos/RepositoryEntry.tsx index 8bd29309aa..80722eecfb 100644 --- a/scm-ui/ui-components/src/repos/RepositoryEntry.tsx +++ b/scm-ui/ui-components/src/repos/RepositoryEntry.tsx @@ -28,8 +28,13 @@ import RepositoryEntryLink from "./RepositoryEntryLink"; import RepositoryAvatar from "./RepositoryAvatar"; import { ExtensionPoint } from "@scm-manager/ui-extensions"; +type DateProp = Date | string; + type Props = { repository: Repository; + // @VisibleForTesting + // the baseDate is only to avoid failing snapshot tests + baseDate?: DateProp; }; class RepositoryEntry extends React.Component { @@ -77,10 +82,10 @@ class RepositoryEntry extends React.Component { ); }; - createFooterRight = (repository: Repository) => { + createFooterRight = (repository: Repository, baseDate?: DateProp) => { return ( - + ); }; @@ -95,10 +100,10 @@ class RepositoryEntry extends React.Component { }; render() { - const { repository } = this.props; + const { repository, baseDate } = this.props; const repositoryLink = this.createLink(repository); const footerLeft = this.createFooterLeft(repository, repositoryLink); - const footerRight = this.createFooterRight(repository); + const footerRight = this.createFooterRight(repository, baseDate); const title = this.createTitle(); return (