From 15f3e51f8df1a3df1163b2162be183096a92e228 Mon Sep 17 00:00:00 2001 From: Quentin Valmori Date: Fri, 17 Jan 2020 15:08:11 +0100 Subject: [PATCH] test: Add snapshot for SharedStatus --- .../src/components/SharedStatus.jsx | 2 +- .../src/components/SharedStatus.spec.js | 45 +++++ .../__snapshots__/SharedStatus.spec.js.snap | 158 ++++++++++++++++++ packages/cozy-sharing/test/AppLike.jsx | 15 ++ 4 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 packages/cozy-sharing/src/components/SharedStatus.spec.js create mode 100644 packages/cozy-sharing/src/components/__snapshots__/SharedStatus.spec.js.snap create mode 100644 packages/cozy-sharing/test/AppLike.jsx diff --git a/packages/cozy-sharing/src/components/SharedStatus.jsx b/packages/cozy-sharing/src/components/SharedStatus.jsx index b0603b86ed..0987e18668 100644 --- a/packages/cozy-sharing/src/components/SharedStatus.jsx +++ b/packages/cozy-sharing/src/components/SharedStatus.jsx @@ -7,7 +7,7 @@ import { Contact } from '../models' import styles from './status.styl' import LinkIcon from '../../assets/icons/icon-link.svg' -const SharedStatus = ({ className, docId, recipients, link, t }) => ( +export const SharedStatus = ({ className, docId, recipients, link, t }) => ( {recipients.length > 1 && ( { + it('should just render a span if no sharing', () => { + const component = mount( + + + + ) + expect(component).toMatchSnapshot() + }) + + it('should have the right display if there is several recipients', () => { + const component = mount( + + x} + /> + + ) + expect(component).toMatchSnapshot() + }) + + it('should display the link if there is a link', () => { + const component = mount( + + x} link={true} /> + + ) + expect(component).toMatchSnapshot() + }) +}) diff --git a/packages/cozy-sharing/src/components/__snapshots__/SharedStatus.spec.js.snap b/packages/cozy-sharing/src/components/__snapshots__/SharedStatus.spec.js.snap new file mode 100644 index 0000000000..ab662f71db --- /dev/null +++ b/packages/cozy-sharing/src/components/__snapshots__/SharedStatus.spec.js.snap @@ -0,0 +1,158 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SharedStatus component should display the link if there is a link 1`] = ` + + + + + + + + + + + + + + + + + + +`; + +exports[`SharedStatus component should have the right display if there is several recipients 1`] = ` + + + + + + + Share.members.count + + + +
+ +
    +
  • + 1 +
  • +
  • + 2 +
  • +
+
+
+
+
+
+ + + + +`; + +exports[`SharedStatus component should just render a span if no sharing 1`] = ` + + + + + + + + + +`; diff --git a/packages/cozy-sharing/test/AppLike.jsx b/packages/cozy-sharing/test/AppLike.jsx new file mode 100644 index 0000000000..560a642cc5 --- /dev/null +++ b/packages/cozy-sharing/test/AppLike.jsx @@ -0,0 +1,15 @@ +import React from 'react' +import { I18n } from 'cozy-ui/transpiled/react' +import langEn from '../locales/en.json' + +export const TestI18n = ({ children }) => { + return ( + langEn}> + {children} + + ) +} + +const AppLike = ({ children }) => {children} + +export default AppLike