From aa30ebf5a96f93701c3159dfc688540efc6f2c12 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Fri, 30 Sep 2022 11:49:03 +0200 Subject: [PATCH] NO-JIRA Migrate icon enzyme test --- .../icons/__tests__/BranchLikeIcon-test.tsx | 14 +++++------ .../components/icons/__tests__/Icon-test.tsx | 9 ++++---- .../BranchLikeIcon-test.tsx.snap | 4 ++-- .../__snapshots__/Icon-test.tsx.snap | 23 +------------------ 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx b/server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx index a0281f3434c..307506edf41 100644 --- a/server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx +++ b/server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx @@ -17,21 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { shallow } from 'enzyme'; +import { render } from '@testing-library/react'; import * as React from 'react'; import { mockBranch, mockPullRequest } from '../../../helpers/mocks/branch-like'; import BranchLikeIcon, { BranchLikeIconProps } from '../BranchLikeIcon'; it('should render branch icon correctly', () => { - const wrapper = shallowRender({ branchLike: mockBranch() }); - expect(wrapper).toMatchSnapshot(); + renderBranchLikeIcon({ branchLike: mockBranch() }); + expect(document.body.innerHTML).toMatchSnapshot(); }); it('should render pull request icon correctly', () => { - const wrapper = shallowRender({ branchLike: mockPullRequest() }); - expect(wrapper).toMatchSnapshot(); + renderBranchLikeIcon({ branchLike: mockPullRequest() }); + expect(document.body.innerHTML).toMatchSnapshot(); }); -function shallowRender(props: BranchLikeIconProps) { - return shallow(); +function renderBranchLikeIcon(props: BranchLikeIconProps) { + return render(); } diff --git a/server/sonar-web/src/main/js/components/icons/__tests__/Icon-test.tsx b/server/sonar-web/src/main/js/components/icons/__tests__/Icon-test.tsx index d67e1713a1b..59cac0c9a40 100644 --- a/server/sonar-web/src/main/js/components/icons/__tests__/Icon-test.tsx +++ b/server/sonar-web/src/main/js/components/icons/__tests__/Icon-test.tsx @@ -17,16 +17,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { shallow } from 'enzyme'; +import { render } from '@testing-library/react'; import * as React from 'react'; import Icon, { IconProps } from '../Icon'; it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); + renderIcon(); + expect(document.body.innerHTML).toMatchSnapshot(); }); -function shallowRender(props: Partial = {}) { - return shallow( +function renderIcon(props: Partial = {}) { + return render( diff --git a/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap b/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap index 3387e59a0a7..fa08036ef71 100644 --- a/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`should render branch icon correctly 1`] = ``; +exports[`should render branch icon correctly 1`] = `"
"`; -exports[`should render pull request icon correctly 1`] = ``; +exports[`should render pull request icon correctly 1`] = `"
"`; diff --git a/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/Icon-test.tsx.snap b/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/Icon-test.tsx.snap index a61c0314f87..8ff807bdf67 100644 --- a/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/Icon-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/Icon-test.tsx.snap @@ -1,24 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`should render correctly 1`] = ` - - - -`; +exports[`should render correctly 1`] = `"
"`; -- 2.39.5