From b37995e2f3b1d8d102151c0b3a0e9da6898e63cf Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Tue, 21 Jun 2022 14:56:22 +0200 Subject: [PATCH] tests --- jest.config.js | 1 + src/components/Options/MatomoOptOut.spec.tsx | 20 +++++++++++++++ .../__snapshots__/MatomoOptOut.spec.tsx.snap | 25 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/components/Options/MatomoOptOut.spec.tsx create mode 100644 src/components/Options/__snapshots__/MatomoOptOut.spec.tsx.snap diff --git a/jest.config.js b/jest.config.js index 6cf339521..b6a027a5b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -18,6 +18,7 @@ module.exports = { globals: { __ALLOW_HTTP__: false, __TARGET__: 'browser', + __PIWIK_TRACKER_URL__: 'http://localhost:9800/', cozy: {}, }, } diff --git a/src/components/Options/MatomoOptOut.spec.tsx b/src/components/Options/MatomoOptOut.spec.tsx new file mode 100644 index 000000000..11ca22001 --- /dev/null +++ b/src/components/Options/MatomoOptOut.spec.tsx @@ -0,0 +1,20 @@ +import React from 'react' +import { shallow } from 'enzyme' +import { MatomoOptOut } from './MatomoOptOut' + +jest.mock('cozy-ui/transpiled/react/I18n', () => { + return { + useI18n: jest.fn(() => { + return { + t: (str: string) => str, + } + }), + } +}) + +describe('MatomoOptOut component', () => { + it('should be rendered correctly', () => { + const component = shallow(<MatomoOptOut />).getElement() + expect(component).toMatchSnapshot() + }) +}) diff --git a/src/components/Options/__snapshots__/MatomoOptOut.spec.tsx.snap b/src/components/Options/__snapshots__/MatomoOptOut.spec.tsx.snap new file mode 100644 index 000000000..599b28c0a --- /dev/null +++ b/src/components/Options/__snapshots__/MatomoOptOut.spec.tsx.snap @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`MatomoOptOut component should be rendered correctly 1`] = ` +<div + className="matomo-opt-out-container" +> + <div + className="matomo-opt-out" + > + <div + className="opt-out-header text-16-normal-uppercase" + > + matomo.matomo_title + </div> + <iframe + src="http://localhost:9800/index.php?module=CoreAdminHome&action=optOut&language=fr&backgroundColor=121212&fontColor=e0e0e0&fontSize=&fontFamily=sans-serif" + style={ + Object { + "height": "250px", + } + } + /> + </div> +</div> +`; -- GitLab