]> source.dussan.org Git - sonarqube.git/commitdiff
NO-JIRA Migrate icon enzyme test
authorMathieu Suen <mathieu.suen@sonarsource.com>
Fri, 30 Sep 2022 09:49:03 +0000 (11:49 +0200)
committerPhilippe Perrin <philippe.perrin@sonarsource.com>
Fri, 7 Oct 2022 10:13:56 +0000 (12:13 +0200)
server/sonar-web/src/main/js/components/icons/__tests__/BranchLikeIcon-test.tsx
server/sonar-web/src/main/js/components/icons/__tests__/Icon-test.tsx
server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/BranchLikeIcon-test.tsx.snap
server/sonar-web/src/main/js/components/icons/__tests__/__snapshots__/Icon-test.tsx.snap

index a0281f3434c8d2bab7da2597a30182524fe58a1a..307506edf415e965a185f74d4fc41a018a0a46a6 100644 (file)
  * 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(<BranchLikeIcon {...props} />);
+function renderBranchLikeIcon(props: BranchLikeIconProps) {
+  return render(<BranchLikeIcon {...props} />);
 }
index d67e1713a1b79fd2504a9d5004f84324cc943ce6..59cac0c9a40ec6fa0f9a9a09e62f273244387164 100644 (file)
  * 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<IconProps> = {}) {
-  return shallow(
+function renderIcon(props: Partial<IconProps> = {}) {
+  return render(
     <Icon {...props}>
       <path d="test-path" />
     </Icon>
index 3387e59a0a7fe38c3cfb4194d3e820c2e22b1ead..fa08036ef71492e4108080729af433909ba04c88 100644 (file)
@@ -1,5 +1,5 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
-exports[`should render branch icon correctly 1`] = `<BranchIcon />`;
+exports[`should render branch icon correctly 1`] = `"<div><svg height=\\"16\\" style=\\"fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 1.41421;\\" version=\\"1.1\\" viewBox=\\"0 0 16 16\\" width=\\"16\\" xmlns:xlink=\\"http://www.w3.org/1999/xlink\\" xml:space=\\"preserve\\"><path d=\\"M12.5 6.5c0-1.1-.9-2-2-2s-2 .9-2 2c0 .8.5 1.5 1.2 1.8-.3.6-.7 1.1-1.2 1.4-.9.5-1.9.5-2.5.4V4c.9-.2 1.5-1 1.5-1.9 0-1.1-.9-2-2-2s-2 .9-2 2C3.5 3 4.1 3.8 5 4v8c-.9.2-1.5 1-1.5 1.9 0 1.1.9 2 2 2s2-.9 2-2c0-.9-.6-1.7-1.5-1.9v-1c.2 0 .5.1.7.1.7 0 1.5-.1 2.2-.6.8-.5 1.4-1.2 1.7-2.1 1.1 0 1.9-.9 1.9-1.9zm-8-4.4c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1-1-.5-1-1zm2 11.9c0 .6-.4 1-1 1s-1-.4-1-1 .4-1 1-1 1 .4 1 1zm4-6.5c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1z\\" style=\\"fill: #236a97;\\"></path></svg></div>"`;
 
-exports[`should render pull request icon correctly 1`] = `<PullRequestIcon />`;
+exports[`should render pull request icon correctly 1`] = `"<div><svg height=\\"16\\" style=\\"fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 1.41421;\\" version=\\"1.1\\" viewBox=\\"0 0 16 16\\" width=\\"16\\" xmlns:xlink=\\"http://www.w3.org/1999/xlink\\" xml:space=\\"preserve\\"><path d=\\"M13,11.9L13,5.5C13,5.4 13.232,1.996 7.9,2L9.1,0.8L8.5,0.1L5.9,2.6L8.5,5.1L9.2,4.4L7.905,3.008C12.256,2.99 12,5.4 12,5.5L12,11.9C11.1,12.1 10.5,12.9 10.5,13.8C10.5,14.9 11.4,15.8 12.5,15.8C13.6,15.8 14.5,14.9 14.5,13.8C14.5,12.9 13.9,12.2 13,11.9ZM4,11.9C4.9,12.2 5.5,12.9 5.5,13.8C5.5,14.9 4.6,15.8 3.5,15.8C2.4,15.8 1.5,14.9 1.5,13.8C1.5,12.9 2.1,12.1 3,11.9L3,4.1C2.1,3.9 1.5,3.1 1.5,2.2C1.5,1.1 2.4,0.2 3.5,0.2C4.6,0.2 5.5,1.1 5.5,2.2C5.5,3.1 4.9,3.9 4,4.1L4,11.9ZM12.5,14.9C11.9,14.9 11.5,14.5 11.5,13.9C11.5,13.3 11.9,12.9 12.5,12.9C13.1,12.9 13.5,13.3 13.5,13.9C13.5,14.5 13.1,14.9 12.5,14.9ZM3.5,14.9C2.9,14.9 2.5,14.5 2.5,13.9C2.5,13.3 2.9,12.9 3.5,12.9C4.1,12.9 4.5,13.3 4.5,13.9C4.5,14.5 4.1,14.9 3.5,14.9ZM2.5,2.2C2.5,1.6 2.9,1.2 3.5,1.2C4.1,1.2 4.5,1.6 4.5,2.2C4.5,2.8 4.1,3.2 3.5,3.2C2.9,3.2 2.5,2.8 2.5,2.2Z\\" style=\\"fill: #236a97;\\"></path></svg></div>"`;
index a61c0314f8722b75119a2d5bec6fb4c9b1381a9c..8ff807bdf67cc1f99d4dcd20b13f0089f3badcdc 100644 (file)
@@ -1,24 +1,3 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
-exports[`should render correctly 1`] = `
-<svg
-  height={16}
-  style={
-    Object {
-      "clipRule": "evenodd",
-      "fillRule": "evenodd",
-      "strokeLinejoin": "round",
-      "strokeMiterlimit": 1.41421,
-    }
-  }
-  version="1.1"
-  viewBox="0 0 16 16"
-  width={16}
-  xmlSpace="preserve"
-  xmlnsXlink="http://www.w3.org/1999/xlink"
->
-  <path
-    d="test-path"
-  />
-</svg>
-`;
+exports[`should render correctly 1`] = `"<div><svg height=\\"16\\" style=\\"fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 1.41421;\\" version=\\"1.1\\" viewBox=\\"0 0 16 16\\" width=\\"16\\" xmlns:xlink=\\"http://www.w3.org/1999/xlink\\" xml:space=\\"preserve\\"><path d=\\"test-path\\"></path></svg></div>"`;