diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7d8b327a08..c16eb3c4ac 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -47,10 +47,8 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/setup_modules - uses: ./.github/actions/build_cache_read - - name: Tests without snapshots - run: yarn test:noSnapshots - - name: Tests snapshots - run: yarn test:snapshots + - name: Tests + run: yarn test - name: BundleMon uses: lironer/bundlemon-action@v1 argosDesktop: diff --git a/jest.config.js b/jest.config.js index 2b665d537e..2979157203 100644 --- a/jest.config.js +++ b/jest.config.js @@ -21,6 +21,5 @@ module.exports = { globals: { __ALLOW_HTTP__: false, cozy: {} - }, - snapshotSerializers: ['enzyme-to-json/serializer'] + } } diff --git a/package.json b/package.json index 986c5cb577..6d06f7a76c 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,6 @@ "sprite": "scripts/make-icon-sprite.sh", "screenshots": "node scripts/screenshots.js --screenshot-dir ./screenshots --styleguide-url file://$(pwd)/build/react --kss-dir ./build/styleguide", "test": "jest", - "test:noSnapshots": "jest --testPathIgnorePatterns 'react/examples.spec.jsx'", - "test:snapshots": "jest react/examples.spec.jsx", "screenshots:server": "nodemon ./scripts/pixelmatch-server/server.js -e js,hbs", "postbuild": "postcss transpiled/react/stylesheet.css --replace", "travis-deploy-once": "travis-deploy-once", @@ -103,9 +101,6 @@ "css-loader": "0.28.11", "cssnano": "4.1.11", "cssnano-preset-advanced": "4.0.8", - "enzyme": "3.11.0", - "enzyme-adapter-react-16": "1.15.6", - "enzyme-to-json": "3.6.2", "eslint": "8.11.0", "eslint-config-cozy-app": "^6.1.0", "eslint-config-prettier": "8.6.0", @@ -134,7 +129,6 @@ "postcss-cli": "6.1.3", "postcss-loader": "2.1.6", "prettier": "2.6.0", - "pretty": "2.0.0", "prop-types": "15.7.2", "react": "16.12.0", "react-dom": "16.12.0", diff --git a/react/AppIcon/test/AppIcon.spec.js b/react/AppIcon/test/AppIcon.spec.js index dba8b3d3c8..a776e29b9e 100644 --- a/react/AppIcon/test/AppIcon.spec.js +++ b/react/AppIcon/test/AppIcon.spec.js @@ -1,10 +1,17 @@ 'use strict' /* eslint-env jest */ -import { shallow } from 'enzyme' +import { render, screen } from '@testing-library/react' import React from 'react' import { AppIcon } from '..' +import Icon from '../../Icon' + +jest.mock('../../Icon', () => ({ + ...jest.requireActual('../../Icon'), + __esModule: true, + default: jest.fn(() =>
) +})) describe('AppIcon component', () => { const app = {} @@ -20,6 +27,7 @@ describe('AppIcon component', () => { beforeEach(() => { jest.resetModules() + jest.clearAllMocks() successFetchIcon = jest .fn() @@ -33,17 +41,18 @@ describe('AppIcon component', () => { }) it(`renders as loading`, () => { - const wrapper = shallow( + render( ) - const component = wrapper.getElement() - expect(component).toMatchSnapshot() + const loadingElement = screen.getByRole('progressbar') + + expect(loadingElement).toBeInTheDocument() expect(successFetchIcon).toHaveBeenCalledWith(app, domain, secure) expect(console.error).not.toHaveBeenCalled() }) - it(`should provide appData to getIconUrl in order to get icon simply, when oauth not needed`, async done => { + it(`should provide appData to getIconUrl in order to get icon simply, when oauth not needed`, async () => { const app = { name: 'app name', slug: 'slug', @@ -63,92 +72,71 @@ describe('AppIcon component', () => { getIconURL: getIconURLMock }) } - const wrapper = shallow( - { - wrapper.update() - expect(getIconURLMock).toHaveBeenNthCalledWith(1, { - appData: app, - priority: 'stack', - slug: 'slug', - type: 'app' - }) - done() - }} - /> - ) + + render() + + expect(getIconURLMock).toHaveBeenNthCalledWith(1, { + appData: app, + priority: 'stack', + slug: 'slug', + type: 'app' + }) }) - it(`renders correctly`, async done => { - const wrapper = shallow( - { - wrapper.update() - const component = wrapper.getElement() - expect(component).toMatchSnapshot() - expect(successFetchIcon).toHaveBeenCalledWith(app, domain, secure) - expect(console.error).not.toHaveBeenCalled() - done() - }} - /> + it(`renders correctly`, async () => { + render( + ) + + const iconElement = await screen.findByRole('img') + expect(iconElement).toBeInTheDocument() + + expect(successFetchIcon).toHaveBeenCalledWith(app, domain, secure) + expect(console.error).not.toHaveBeenCalled() }) - it(`renders default when fetch error occurs`, async done => { - const wrapper = shallow( - { - wrapper.update() - const component = wrapper.getElement() - expect(component).toMatchSnapshot() - expect(failureFetchIcon).toHaveBeenCalledWith(app, domain, secure) - expect(console.error).not.toHaveBeenCalled() - done() - }} - /> + it(`renders default when fetch error occurs`, async () => { + render( + + ) + + const iconFallbackElement = await screen.findByTestId('icon-component') + expect(iconFallbackElement).toBeInTheDocument() + + expect(failureFetchIcon).toHaveBeenCalledWith(app, domain, secure) + expect(console.error).not.toHaveBeenCalled() + + // Check that the Icon component has been called with a function (CubeIcon function is the default icon) + expect(Icon).toHaveBeenCalledWith( + expect.objectContaining({ + icon: expect.any(Function) + }), + {} ) }) - it(`renders provided fallbackIcon when fetch error occurs`, async done => { - const wrapper = shallow( + it(`renders provided fallbackIcon when fetch error occurs`, async () => { + render( { - wrapper.update() - const component = wrapper.getElement() - expect(component).toMatchSnapshot() - expect(failureFetchIcon).toHaveBeenCalledWith(app, domain, secure) - expect(console.error).not.toHaveBeenCalled() - done() - }} fallbackIcon="warning" /> ) - }) - it(`renders provided fallbackIcon on img error`, async done => { - const wrapper = shallow( - 'notagoodurl'} - onReady={() => { - wrapper.simulate('error') - wrapper.update() - const component = wrapper.getElement() - expect(component).toMatchSnapshot() - done() - }} - fallbackIcon="warning" - /> + const iconFallbackElement = await screen.findByTestId('icon-component') + expect(iconFallbackElement).toBeInTheDocument() + + expect(failureFetchIcon).toHaveBeenCalledWith(app, domain, secure) + expect(console.error).not.toHaveBeenCalled() + + // Check that the Icon component has been called with "warning" + expect(Icon).toHaveBeenCalledWith( + expect.objectContaining({ + icon: 'warning' + }), + {} ) }) }) diff --git a/react/AppIcon/test/__snapshots__/AppIcon.spec.js.snap b/react/AppIcon/test/__snapshots__/AppIcon.spec.js.snap deleted file mode 100644 index 24f7e7e233..0000000000 --- a/react/AppIcon/test/__snapshots__/AppIcon.spec.js.snap +++ /dev/null @@ -1,49 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AppIcon component renders as loading 1`] = ` -
-`; - -exports[`AppIcon component renders correctly 1`] = ` - -`; - -exports[`AppIcon component renders default when fetch error occurs 1`] = ` - -`; - -exports[`AppIcon component renders provided fallbackIcon on img error 1`] = ` - -`; - -exports[`AppIcon component renders provided fallbackIcon when fetch error occurs 1`] = ` - -`; diff --git a/react/AppSections/__snapshots__/index.spec.jsx.snap b/react/AppSections/__snapshots__/index.spec.jsx.snap deleted file mode 100644 index 97758b875a..0000000000 --- a/react/AppSections/__snapshots__/index.spec.jsx.snap +++ /dev/null @@ -1,1843 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AppsSection component should be rendered correctly with apps list, subtitle and onAppClick 1`] = ` -
- - Applications - -
-
- ", - "installed": true, - "isInRegistry": true, - "label": 1, - "name": "Collect", - "name_prefix": "Cozy", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://collect.cozy.mock/", - "slug": "collect", - "tags": Array [ - "konnector", - "collect", - "bills", - "providers", - "files", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0", - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "installed": true, - "name": "Drive", - "name_prefix": "Cozy", - "permissions": Object { - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://drive.cozy.mock/", - "slug": "drive", - "tags": Array [ - "search", - "files", - "folders", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0-beta89bnhj3993", - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "isInRegistry": true, - "locales": Object { - "en": Object { - "long_description": "A long description finally short", - }, - }, - "name": "Photos", - "name_prefix": "Cozy", - "slug": "photos", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - The essentials - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Tasky", - "slug": "tasky", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - "1.0.0", - ], - "dev": Array [ - "3.0.0", - "1.0.0", - ], - "stable": Array [ - "3.0.0", - "1.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Partners - - } - /> - ", - "isInRegistry": true, - "locales": Object { - "name": "For Dev Only", - }, - "name": "DevOnly", - "slug": "devonly", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [], - "dev": Array [ - "1.0.0-betaojdkehy989ekhflldh", - ], - "stable": Array [], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Others - - } - /> -
-
- - Services - - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Mobile and Internet - - } - /> - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Telecom - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Trinlane", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - }, - "slug": "konnector-trinlane", - "tags": Array [ - "transport", - "files", - "bills", - ], - "type": "konnector", - "uninstallable": true, - "version": "0.1.0", - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Transportation - - } - /> -
-
-
-`; - -exports[`AppsSection component should not render dropdown filter on mobile if nav=false flag provided 1`] = ` -
-
-
- ", - "installed": true, - "isInRegistry": true, - "label": 1, - "name": "Collect", - "name_prefix": "Cozy", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://collect.cozy.mock/", - "slug": "collect", - "tags": Array [ - "konnector", - "collect", - "bills", - "providers", - "files", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0", - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "installed": true, - "name": "Drive", - "name_prefix": "Cozy", - "permissions": Object { - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://drive.cozy.mock/", - "slug": "drive", - "tags": Array [ - "search", - "files", - "folders", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0-beta89bnhj3993", - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "isInRegistry": true, - "locales": Object { - "en": Object { - "long_description": "A long description finally short", - }, - }, - "name": "Photos", - "name_prefix": "Cozy", - "slug": "photos", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - The essentials - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Tasky", - "slug": "tasky", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - "1.0.0", - ], - "dev": Array [ - "3.0.0", - "1.0.0", - ], - "stable": Array [ - "3.0.0", - "1.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Partners - - } - /> - ", - "isInRegistry": true, - "locales": Object { - "name": "For Dev Only", - }, - "name": "DevOnly", - "slug": "devonly", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [], - "dev": Array [ - "1.0.0-betaojdkehy989ekhflldh", - ], - "stable": Array [], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Others - - } - /> -
-
- - Services - - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Mobile and Internet - - } - /> - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Telecom - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Trinlane", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - }, - "slug": "konnector-trinlane", - "tags": Array [ - "transport", - "files", - "bills", - ], - "type": "konnector", - "uninstallable": true, - "version": "0.1.0", - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Transportation - - } - /> -
-
-
-`; - -exports[`AppsSection component should not render dropdown filter on tablet if nav=false flag provided 1`] = ` -
- - Applications - -
-
- ", - "installed": true, - "isInRegistry": true, - "label": 1, - "name": "Collect", - "name_prefix": "Cozy", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://collect.cozy.mock/", - "slug": "collect", - "tags": Array [ - "konnector", - "collect", - "bills", - "providers", - "files", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0", - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "installed": true, - "name": "Drive", - "name_prefix": "Cozy", - "permissions": Object { - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://drive.cozy.mock/", - "slug": "drive", - "tags": Array [ - "search", - "files", - "folders", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0-beta89bnhj3993", - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "isInRegistry": true, - "locales": Object { - "en": Object { - "long_description": "A long description finally short", - }, - }, - "name": "Photos", - "name_prefix": "Cozy", - "slug": "photos", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - The essentials - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Tasky", - "slug": "tasky", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - "1.0.0", - ], - "dev": Array [ - "3.0.0", - "1.0.0", - ], - "stable": Array [ - "3.0.0", - "1.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Partners - - } - /> - ", - "isInRegistry": true, - "locales": Object { - "name": "For Dev Only", - }, - "name": "DevOnly", - "slug": "devonly", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [], - "dev": Array [ - "1.0.0-betaojdkehy989ekhflldh", - ], - "stable": Array [], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Others - - } - /> -
-
- - Services - - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Mobile and Internet - - } - /> - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Telecom - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Trinlane", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - }, - "slug": "konnector-trinlane", - "tags": Array [ - "transport", - "files", - "bills", - ], - "type": "konnector", - "uninstallable": true, - "version": "0.1.0", - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Transportation - - } - /> -
-
-
-`; - -exports[`AppsSection component should render correctly render message if error provided 1`] = ` -

- This is a test error -

-`; - -exports[`AppsSection component should render dropdown filter on mobile if no nav=false flag provided 1`] = ` -
- -
-
- ", - "installed": true, - "isInRegistry": true, - "label": 1, - "name": "Collect", - "name_prefix": "Cozy", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://collect.cozy.mock/", - "slug": "collect", - "tags": Array [ - "konnector", - "collect", - "bills", - "providers", - "files", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0", - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "installed": true, - "name": "Drive", - "name_prefix": "Cozy", - "permissions": Object { - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://drive.cozy.mock/", - "slug": "drive", - "tags": Array [ - "search", - "files", - "folders", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0-beta89bnhj3993", - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "isInRegistry": true, - "locales": Object { - "en": Object { - "long_description": "A long description finally short", - }, - }, - "name": "Photos", - "name_prefix": "Cozy", - "slug": "photos", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - The essentials - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Tasky", - "slug": "tasky", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - "1.0.0", - ], - "dev": Array [ - "3.0.0", - "1.0.0", - ], - "stable": Array [ - "3.0.0", - "1.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Partners - - } - /> - ", - "isInRegistry": true, - "locales": Object { - "name": "For Dev Only", - }, - "name": "DevOnly", - "slug": "devonly", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [], - "dev": Array [ - "1.0.0-betaojdkehy989ekhflldh", - ], - "stable": Array [], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Others - - } - /> -
-
- - Services - - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Mobile and Internet - - } - /> - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Telecom - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Trinlane", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - }, - "slug": "konnector-trinlane", - "tags": Array [ - "transport", - "files", - "bills", - ], - "type": "konnector", - "uninstallable": true, - "version": "0.1.0", - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Transportation - - } - /> -
-
-
-`; - -exports[`AppsSection component should render dropdown filter on tablet if no nav=false flag provided 1`] = ` -
- - - Applications - -
-
- ", - "installed": true, - "isInRegistry": true, - "label": 1, - "name": "Collect", - "name_prefix": "Cozy", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://collect.cozy.mock/", - "slug": "collect", - "tags": Array [ - "konnector", - "collect", - "bills", - "providers", - "files", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0", - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "installed": true, - "name": "Drive", - "name_prefix": "Cozy", - "permissions": Object { - "mock2": Object { - "type": "io.mock.doctype2", - }, - }, - "related": "http://drive.cozy.mock/", - "slug": "drive", - "tags": Array [ - "search", - "files", - "folders", - ], - "type": "webapp", - "uninstallable": false, - "version": "3.0.0-beta89bnhj3993", - }, - Object { - "categories": Array [ - "cozy", - ], - "developer": Object { - "name": "Cozy", - }, - "editor": "Cozy", - "icon": "", - "isInRegistry": true, - "locales": Object { - "en": Object { - "long_description": "A long description finally short", - }, - }, - "name": "Photos", - "name_prefix": "Cozy", - "slug": "photos", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - ], - "dev": Array [ - "3.0.0", - ], - "stable": Array [ - "3.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - The essentials - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Tasky", - "slug": "tasky", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "3.0.0", - "1.0.0", - ], - "dev": Array [ - "3.0.0", - "1.0.0", - ], - "stable": Array [ - "3.0.0", - "1.0.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Partners - - } - /> - ", - "isInRegistry": true, - "locales": Object { - "name": "For Dev Only", - }, - "name": "DevOnly", - "slug": "devonly", - "type": "webapp", - "uninstallable": true, - "versions": Object { - "beta": Array [], - "dev": Array [ - "1.0.0-betaojdkehy989ekhflldh", - ], - "stable": Array [], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Others - - } - /> -
-
- - Services - - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Mobile and Internet - - } - /> - ", - "isInRegistry": true, - "name": "Bouilligue", - "slug": "konnector-bouilligue", - "type": "konnector", - "uninstallable": true, - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Telecom - - } - /> - ", - "installed": true, - "isInRegistry": true, - "name": "Trinlane", - "permissions": Object { - "mock": Object { - "type": "io.mock.doctype", - }, - }, - "slug": "konnector-trinlane", - "tags": Array [ - "transport", - "files", - "bills", - ], - "type": "konnector", - "uninstallable": true, - "version": "0.1.0", - "versions": Object { - "beta": Array [ - "0.1.0", - ], - "dev": Array [ - "0.1.0", - ], - "stable": Array [ - "0.1.0", - ], - }, - }, - ] - } - displaySpecificMaintenanceStyle={false} - onAppClick={[MockFunction]} - subtitle={ - - Transportation - - } - /> -
-
-
-`; diff --git a/react/AppSections/components/AppsSection.spec.jsx b/react/AppSections/components/AppsSection.spec.jsx index 32da06a17c..7390fe51ed 100644 --- a/react/AppSections/components/AppsSection.spec.jsx +++ b/react/AppSections/components/AppsSection.spec.jsx @@ -2,13 +2,12 @@ /* eslint-env jest */ -import { mount } from 'enzyme' +import { fireEvent, render, screen } from '@testing-library/react' import React from 'react' import { CozyProvider } from 'cozy-client' import { AppsSection } from './AppsSection' -import Tile, { TileTitle, TileSubtitle, TileFooter } from '../../Tile' import { I18nContext } from '../../jestLib/I18n' import mockApps from '../../mocks/apps' import { BreakpointsProvider } from '../../providers/Breakpoints' @@ -19,10 +18,9 @@ const i18nContext = I18nContext({ locale: en }) const tMock = i18nContext.t describe('AppsSection component', () => { - let component const client = {} const setup = ({ onAppClick }) => { - component = mount( + render( en}> @@ -36,31 +34,24 @@ describe('AppsSection component', () => { - ).find(AppsSection) + ) } it('should be rendered correctly with apps list, subtitle', () => { const mockOnAppClick = jest.fn() setup({ onAppClick: mockOnAppClick }) - expect( - component.find(Tile).map(x => { - const developer = x.find(TileSubtitle) - const status = x.find(TileFooter) - return { - title: x.find(TileTitle).text(), - developer: developer.length ? developer.text() : null, - status: status.length ? status.text() : null - } - }) - ).toMatchSnapshot() + + mockApps.forEach(app => { + expect(screen.getByText(app.name, { exact: false })).toBeInTheDocument() + }) }) it('should run provided onAppClick on AppTile click event', () => { const mockOnAppClick = jest.fn() setup({ onAppClick: mockOnAppClick }) - expect(component.find(Tile).length).toBe(mockApps.length) - const appItem = component.find(Tile).at(0) - appItem.simulate('click') + + const bouilligue = screen.getByText('Bouilligue', { exact: false }) + fireEvent.click(bouilligue) expect(mockOnAppClick.mock.calls.length).toBe(1) expect(mockOnAppClick.mock.calls[0][0]).toBe('konnector-bouilligue') }) diff --git a/react/AppSections/components/__snapshots__/AppsSection.spec.jsx.snap b/react/AppSections/components/__snapshots__/AppsSection.spec.jsx.snap deleted file mode 100644 index ec14d0b8ef..0000000000 --- a/react/AppSections/components/__snapshots__/AppsSection.spec.jsx.snap +++ /dev/null @@ -1,41 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AppsSection component should be rendered correctly with apps list, subtitle 1`] = ` -Array [ - Object { - "developer": "By Cozy", - "status": null, - "title": "Bouilligue", - }, - Object { - "developer": "By Cozy", - "status": "Installed", - "title": "Cozy Collect", - }, - Object { - "developer": "By Cozy", - "status": null, - "title": "DevOnly", - }, - Object { - "developer": "By Cozy", - "status": "Installed", - "title": "Cozy Drive", - }, - Object { - "developer": "By Cozy", - "status": null, - "title": "Cozy Photos", - }, - Object { - "developer": null, - "status": "Update available", - "title": "Tasky", - }, - Object { - "developer": "By Cozy", - "status": "Installed", - "title": "Trinlane", - }, -] -`; diff --git a/react/AppSections/index.spec.jsx b/react/AppSections/index.spec.jsx index eae0799d61..5ac8c66526 100644 --- a/react/AppSections/index.spec.jsx +++ b/react/AppSections/index.spec.jsx @@ -2,13 +2,14 @@ /* eslint-env jest */ -import { shallow } from 'enzyme' +import { render, screen } from '@testing-library/react' import React from 'react' import { Sections } from './Sections' import en from './locales/en.json' import { I18nContext } from '../jestLib/I18n' import mockApps from '../mocks/apps' +import DemoProvider from '../providers/DemoProvider' const i18nContext = I18nContext({ locale: en }) const tMock = i18nContext.t @@ -16,101 +17,121 @@ const tMock = i18nContext.t describe('AppsSection component', () => { it('should be rendered correctly with apps list, subtitle and onAppClick', () => { const mockOnAppClick = jest.fn() - const component = shallow( - - ).getElement() - expect(component).toMatchSnapshot() + render( + + + + ) + + expect(screen.queryByText('Cozy Collect')).toBeInTheDocument() + expect(screen.queryByText('Cozy Drive')).toBeInTheDocument() + expect(screen.queryByText('DevOnly')).toBeInTheDocument() }) it('should render correctly render message if error provided', () => { const mockOnAppClick = jest.fn() - const component = shallow( - - ).getElement() - expect(component).toMatchSnapshot() + render( + + + + ) + + expect(screen.queryByText('This is a test error')).toBeInTheDocument() }) it('should not render dropdown filter on mobile if nav=false flag provided', () => { const mockOnAppClick = jest.fn() - const component = shallow( - - ).getElement() - expect(component).toMatchSnapshot() + render( + + + + ) + + expect(screen.queryByText('All categories')).not.toBeInTheDocument() }) it('should not render dropdown filter on tablet if nav=false flag provided', () => { const mockOnAppClick = jest.fn() - const component = shallow( - - ).getElement() - expect(component).toMatchSnapshot() + render( + + + + ) + + expect(screen.queryByText('All categories')).not.toBeInTheDocument() }) it('should render dropdown filter on mobile if no nav=false flag provided', () => { const mockOnAppClick = jest.fn() - const component = shallow( - - ).getElement() - expect(component).toMatchSnapshot() + render( + + + + ) + + expect(screen.queryByText('All categories')).toBeInTheDocument() }) it('should render dropdown filter on tablet if no nav=false flag provided', () => { const mockOnAppClick = jest.fn() - const component = shallow( - - ).getElement() - expect(component).toMatchSnapshot() + render( + + + + ) + + expect(screen.queryByText('All categories')).toBeInTheDocument() }) }) diff --git a/react/ContactsList/ContactRow.spec.js b/react/ContactsList/ContactRow.spec.js index fcc2dd8bfa..98f6f6b4f7 100644 --- a/react/ContactsList/ContactRow.spec.js +++ b/react/ContactsList/ContactRow.spec.js @@ -1,6 +1,5 @@ -import { mount } from 'enzyme' +import { render, screen } from '@testing-library/react' import React from 'react' -import renderer from 'react-test-renderer' import logger from 'cozy-logger' @@ -16,20 +15,22 @@ const makeContact = attrs => ({ }) const setup = ({ contact }) => { - const root = mount( + render( ) - return { root } } describe('ContactRow', () => { it('should accept the strict minimum', () => { const contact = makeContact({ email: [{ address: 'johndoe@localhost' }] }) - const { root } = setup({ contact }) - const contactrowemail = root.find('ContactEmail') - expect(contactrowemail.text()).toBe(contact.email[0].address) + setup({ contact }) + + // With a minimal contact, email is displayed twice + // - one as display name + // - one as email + expect(screen.getAllByText('johndoe@localhost').length).toBe(2) }) it('should display data', () => { @@ -39,62 +40,36 @@ describe('ContactRow', () => { email: [{ address: 'johndoe@localhost' }], cozy: [{ url: 'http://johndoe.mycozy.cloud' }] }) - const { root } = setup({ contact }) - const contactrowname = root.find('ContactName') - expect(contactrowname).toBeDefined() - expect(contactrowname.text()).toEqual( - expect.stringContaining(contact.name.givenName) - ) - expect(contactrowname.text()).toEqual( - expect.stringContaining(contact.name.familyName) - ) - const contactrowphone = root.find('ContactPhone') - expect(contactrowphone).toBeDefined() - expect(contactrowphone.text()).toBe(contact.phone[0].number) + setup({ contact }) - const contactrowcozyurl = root.find('ContactCozy') - expect(contactrowcozyurl).toBeDefined() - expect(contactrowcozyurl.text()).toBe(contact.cozy[0].url) + // We need to check first and last name separatly because they are in two different span + expect(screen.getByText('John')).toBeInTheDocument() + expect(screen.getByText('Doe')).toBeInTheDocument() + expect(screen.getByText('0123456789')).toBeInTheDocument() + expect(screen.getByText('johndoe@localhost')).toBeInTheDocument() + expect(screen.getByText('http://johndoe.mycozy.cloud')).toBeInTheDocument() }) it('should display email for missing information', () => { const contact = makeContact({ email: [{ address: 'johndoe@localhost' }] }) - const { root } = setup({ contact }) - const contactrowname = root.find('ContactName') - expect(contactrowname).toBeDefined() - expect(contactrowname.text().trim()).toBe('johndoe@localhost') - const contactrowphone = root.find('ContactPhone') - expect(contactrowphone).toBeDefined() - expect(contactrowphone.text().trim()).toBe('—') - const contactrowcozyurl = root.find('ContactCozy') - expect(contactrowcozyurl).toBeDefined() - expect(contactrowcozyurl.text().trim()).toBe('—') + setup({ contact }) + + const emailColumn = screen.getByTestId('ContactEmail') + expect(emailColumn.textContent).toBe('johndoe@localhost') + + const phoneColumn = screen.getByTestId('ContactPhone') + expect(phoneColumn.textContent).toBe('—') + + const cozyColumn = screen.getByTestId('ContactCozy') + expect(cozyColumn.textContent).toBe('—') }) it('should accept empty array', () => { const contact = makeContact({ email: [] }) - const { root } = setup({ contact }) - const contactrowemail = root.find('ContactEmail') - expect(contactrowemail).toBeDefined() - expect(contactrowemail.text()).toBe('—') - }) - - it('should match the contact snapshot', () => { - const contact = makeContact({ - name: { familyName: 'Doe', givenName: 'John' }, - phone: [{ number: '0123456789' }], - email: [{ address: 'johndoe@localhost' }], - cozy: [{ url: 'http://johndoe.mycozy.cloud' }] - }) - const tree = renderer - .create( - - - - ) - .toJSON() - expect(tree).toMatchSnapshot() + setup({ contact }) + const emailColumn = screen.getByTestId('ContactEmail') + expect(emailColumn.textContent).toBe('—') }) }) diff --git a/react/ContactsList/__snapshots__/ContactRow.spec.js.snap b/react/ContactsList/__snapshots__/ContactRow.spec.js.snap deleted file mode 100644 index 09d57fb512..0000000000 --- a/react/ContactsList/__snapshots__/ContactRow.spec.js.snap +++ /dev/null @@ -1,69 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ContactRow should match the contact snapshot 1`] = ` -
  • -
    -
    - - - JD - -
    -

    - - John -   - - - Doe -   - -

    -
    -
    - johndoe@localhost -
    -
    - 0123456789 -
    -
    - http://johndoe.mycozy.cloud -
    -
  • -`; diff --git a/react/DateMonthPicker/index.spec.jsx b/react/DateMonthPicker/index.spec.jsx index ee2a882913..8d0e09dfaa 100644 --- a/react/DateMonthPicker/index.spec.jsx +++ b/react/DateMonthPicker/index.spec.jsx @@ -1,36 +1,13 @@ -import { mount } from 'enzyme' +import { fireEvent, render, screen } from '@testing-library/react' import React from 'react' -import { act } from 'react-dom/test-utils' import DateMonthPicker from '.' -import LeftIcon from '../Icons/Left' -import RightIcon from '../Icons/Right' import I18n from '../providers/I18n' -const findButtonWithLabel = (root, label) => - root.findWhere(n => n.type() == 'button' && n.props().children === label) - -const findButtonWithIcon = (root, iconName) => - root.findWhere(n => { - const props = n.props() - if (n.type() !== 'button') { - return - } - if (!props.children || !props.children.length > 1) { - return - } - - return ( - props.children.props && - props.children.props.icon && - props.children.props.icon == iconName - ) - }) - describe('DateMonthPicker', () => { const setup = ({ initialValue }) => { const handleSelect = jest.fn() - const root = mount( + const root = render( {}}> @@ -39,36 +16,31 @@ describe('DateMonthPicker', () => { } it('should be able to select a month', async () => { - const { root, handleSelect } = setup({ initialValue: '2015-08' }) - const februaryButton = findButtonWithLabel(root, 'Feb') - expect(februaryButton.length).toBe(1) - februaryButton.props().onClick() + const { handleSelect } = setup({ initialValue: '2015-08' }) + const februaryButton = screen.getByText('Feb') + fireEvent.click(februaryButton) expect(handleSelect).toHaveBeenCalledTimes(1) expect(handleSelect).toHaveBeenCalledWith('2015-02-01') }) it('should be able to go to previous year', async () => { - const { root, handleSelect } = setup({ initialValue: '2015-08' }) - const prevYearButton = findButtonWithIcon(root, LeftIcon) - act(() => { - prevYearButton.props().onClick() - }) - root.update() - const februaryButton = findButtonWithLabel(root, 'Feb') - februaryButton.props().onClick() + const { handleSelect } = setup({ initialValue: '2015-08' }) + // Left arrow to go to previous year is first button + const previousYearButton = screen.getAllByRole('button')[0] + fireEvent.click(previousYearButton) + const februaryButton = screen.getByText('Feb') + fireEvent.click(februaryButton) expect(handleSelect).toHaveBeenCalledTimes(1) expect(handleSelect).toHaveBeenCalledWith('2014-02-01') }) it('should be able to go to next year', async () => { - const { root, handleSelect } = setup({ initialValue: '2015-08' }) - const nextYearButton = findButtonWithIcon(root, RightIcon) - act(() => { - nextYearButton.props().onClick() - }) - root.update() - const februaryButton = findButtonWithLabel(root, 'Feb') - februaryButton.props().onClick() + const { handleSelect } = setup({ initialValue: '2015-08' }) + // Right arrow to go to next year is first button + const nextYearButton = screen.getAllByRole('button')[1] + fireEvent.click(nextYearButton) + const februaryButton = screen.getByText('Feb') + fireEvent.click(februaryButton) expect(handleSelect).toHaveBeenCalledTimes(1) expect(handleSelect).toHaveBeenCalledWith('2016-02-01') }) diff --git a/react/Field/index.spec.js b/react/Field/index.spec.js index 0a650724b5..2448b5267b 100644 --- a/react/Field/index.spec.js +++ b/react/Field/index.spec.js @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme' +import { render } from '@testing-library/react' import React from 'react' import Field from '.' @@ -18,19 +18,42 @@ describe('Field component', () => { it('should expect object type value for type=select', () => { expect(() => - shallow() + render( + {}} + /> + ) ).not.toThrowError() expect(() => - shallow() + render( + {}} + /> + ) ).toThrowError() }) it('should expect string type value for all types but select', () => { expect(() => - shallow() + render( + {}} + /> + ) ).not.toThrowError() expect(() => - shallow() + render( + {}} /> + ) ).toThrowError() }) }) diff --git a/react/Figure/Figure.spec.jsx b/react/Figure/Figure.spec.jsx index a462a547b5..49d67677ec 100644 --- a/react/Figure/Figure.spec.jsx +++ b/react/Figure/Figure.spec.jsx @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme' +import { render } from '@testing-library/react' import { flatten, merge } from 'lodash' import React from 'react' @@ -39,13 +39,18 @@ describe('Figure', () => { return merge.apply(null, [{}, ...attrs]) }) + // We check for different king of amounts if + // - its red if it is negative if coloredNegative is set + // - its green if it is positive if coloredPositive is set + // - its yellow if it is above the warning limit if coloredWarning is set + for (let amount of amounts) { for (let attrs of combinations) { it(`should render correctly ${amount} ${formatAttrs(attrs)}`, () => { - const el = shallow( + const { container } = render(
    - ).getElement() - expect(el).toMatchSnapshot() + ) + expect(container).toMatchSnapshot() }) } } diff --git a/react/Figure/__snapshots__/Figure.spec.jsx.snap b/react/Figure/__snapshots__/Figure.spec.jsx.snap index 8cfec93499..a5d529f7d8 100644 --- a/react/Figure/__snapshots__/Figure.spec.jsx.snap +++ b/react/Figure/__snapshots__/Figure.spec.jsx.snap @@ -1,385 +1,449 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Figure should render correctly -100 coloredPositive: false, coloredNegative: false, coloredWarning: false 1`] = ` -
    - +
    - -100,00 - + + -100,00 + +
    `; exports[`Figure should render correctly -100 coloredPositive: false, coloredNegative: false, coloredWarning: true 1`] = ` -
    - +
    - -100,00 - + + -100,00 + +
    `; exports[`Figure should render correctly -100 coloredPositive: false, coloredNegative: true, coloredWarning: false 1`] = ` -
    - +
    - -100,00 - + + -100,00 + +
    `; exports[`Figure should render correctly -100 coloredPositive: false, coloredNegative: true, coloredWarning: true 1`] = ` -
    - +
    - -100,00 - + + -100,00 + +
    `; exports[`Figure should render correctly -100 coloredPositive: true, coloredNegative: false, coloredWarning: false 1`] = ` -
    - +
    - -100,00 - + + -100,00 + +
    `; exports[`Figure should render correctly -100 coloredPositive: true, coloredNegative: false, coloredWarning: true 1`] = ` -
    - +
    - -100,00 - + + -100,00 + +
    `; exports[`Figure should render correctly -100 coloredPositive: true, coloredNegative: true, coloredWarning: false 1`] = ` -
    - +
    - -100,00 - + + -100,00 + +
    `; exports[`Figure should render correctly -100 coloredPositive: true, coloredNegative: true, coloredWarning: true 1`] = ` -
    - +
    - -100,00 - + + -100,00 + +
    `; exports[`Figure should render correctly 4 coloredPositive: false, coloredNegative: false, coloredWarning: false 1`] = ` -
    - +
    - 4,00 - + + 4,00 + +
    `; exports[`Figure should render correctly 4 coloredPositive: false, coloredNegative: false, coloredWarning: true 1`] = ` -
    - +
    - 4,00 - + + 4,00 + +
    `; exports[`Figure should render correctly 4 coloredPositive: false, coloredNegative: true, coloredWarning: false 1`] = ` -
    - +
    - 4,00 - + + 4,00 + +
    `; exports[`Figure should render correctly 4 coloredPositive: false, coloredNegative: true, coloredWarning: true 1`] = ` -
    - +
    - 4,00 - + + 4,00 + +
    `; exports[`Figure should render correctly 4 coloredPositive: true, coloredNegative: false, coloredWarning: false 1`] = ` -
    - +
    - 4,00 - + + 4,00 + +
    `; exports[`Figure should render correctly 4 coloredPositive: true, coloredNegative: false, coloredWarning: true 1`] = ` -
    - +
    - 4,00 - + + 4,00 + +
    `; exports[`Figure should render correctly 4 coloredPositive: true, coloredNegative: true, coloredWarning: false 1`] = ` -
    - +
    - 4,00 - + + 4,00 + +
    `; exports[`Figure should render correctly 4 coloredPositive: true, coloredNegative: true, coloredWarning: true 1`] = ` -
    - +
    - 4,00 - + + 4,00 + +
    `; exports[`Figure should render correctly 100 coloredPositive: false, coloredNegative: false, coloredWarning: false 1`] = ` -
    - +
    - 100,00 - + + 100,00 + +
    `; exports[`Figure should render correctly 100 coloredPositive: false, coloredNegative: false, coloredWarning: true 1`] = ` -
    - +
    - 100,00 - + + 100,00 + +
    `; exports[`Figure should render correctly 100 coloredPositive: false, coloredNegative: true, coloredWarning: false 1`] = ` -
    - +
    - 100,00 - + + 100,00 + +
    `; exports[`Figure should render correctly 100 coloredPositive: false, coloredNegative: true, coloredWarning: true 1`] = ` -
    - +
    - 100,00 - + + 100,00 + +
    `; exports[`Figure should render correctly 100 coloredPositive: true, coloredNegative: false, coloredWarning: false 1`] = ` -
    - +
    - 100,00 - + + 100,00 + +
    `; exports[`Figure should render correctly 100 coloredPositive: true, coloredNegative: false, coloredWarning: true 1`] = ` -
    - +
    - 100,00 - + + 100,00 + +
    `; exports[`Figure should render correctly 100 coloredPositive: true, coloredNegative: true, coloredWarning: false 1`] = ` -
    - +
    - 100,00 - + + 100,00 + +
    `; exports[`Figure should render correctly 100 coloredPositive: true, coloredNegative: true, coloredWarning: true 1`] = ` -
    - +
    - 100,00 - + + 100,00 + +
    `; exports[`Figure should render correctly 500 coloredPositive: false, coloredNegative: false, coloredWarning: false 1`] = ` -
    - +
    - 500,00 - + + 500,00 + +
    `; exports[`Figure should render correctly 500 coloredPositive: false, coloredNegative: false, coloredWarning: true 1`] = ` -
    - +
    - 500,00 - + + 500,00 + +
    `; exports[`Figure should render correctly 500 coloredPositive: false, coloredNegative: true, coloredWarning: false 1`] = ` -
    - +
    - 500,00 - + + 500,00 + +
    `; exports[`Figure should render correctly 500 coloredPositive: false, coloredNegative: true, coloredWarning: true 1`] = ` -
    - +
    - 500,00 - + + 500,00 + +
    `; exports[`Figure should render correctly 500 coloredPositive: true, coloredNegative: false, coloredWarning: false 1`] = ` -
    - +
    - 500,00 - + + 500,00 + +
    `; exports[`Figure should render correctly 500 coloredPositive: true, coloredNegative: false, coloredWarning: true 1`] = ` -
    - +
    - 500,00 - + + 500,00 + +
    `; exports[`Figure should render correctly 500 coloredPositive: true, coloredNegative: true, coloredWarning: false 1`] = ` -
    - +
    - 500,00 - + + 500,00 + +
    `; exports[`Figure should render correctly 500 coloredPositive: true, coloredNegative: true, coloredWarning: true 1`] = ` -
    - - 500,00 - +
    +
    + + 500,00 + +
    `; diff --git a/react/FileInput/__snapshots__/index.spec.jsx.snap b/react/FileInput/__snapshots__/index.spec.jsx.snap deleted file mode 100644 index 2ae6c694c0..0000000000 --- a/react/FileInput/__snapshots__/index.spec.jsx.snap +++ /dev/null @@ -1,86 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`FileInput component should pass props to the input 1`] = ` - -`; - -exports[`FileInput component should render a default file selector 1`] = ` - -`; - -exports[`FileInput component should render a disabled file selector 1`] = ` - -`; - -exports[`FileInput component should render a file selector 1`] = ` - -`; diff --git a/react/FileInput/index.jsx b/react/FileInput/index.jsx index 80e77eb4d3..561f8399b6 100644 --- a/react/FileInput/index.jsx +++ b/react/FileInput/index.jsx @@ -47,6 +47,7 @@ const FileInput = ({ onChange(Array.from(e.target.files)[0]) } }} + data-testid="file-input" {...inputProps} /> diff --git a/react/FileInput/index.spec.jsx b/react/FileInput/index.spec.jsx index 70da94f57a..9ae8656b7c 100644 --- a/react/FileInput/index.spec.jsx +++ b/react/FileInput/index.spec.jsx @@ -1,3 +1,4 @@ +import { fireEvent, render, screen } from '@testing-library/react' import uniqueId from 'lodash/uniqueId' import React from 'react' @@ -20,66 +21,43 @@ describe('FileInput component', () => { }) it('should render a file selector', () => { - const component = shallow( + render( Click me - ).getElement() - expect(component).toMatchSnapshot() - }) - - it('should render a default file selector', () => { - const component = shallow( -