diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2020-09-22 14:20:28 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-09-28 20:07:23 +0000 |
commit | 71cc0592365fc7ff36694c726c1a8ca4e1fcc6cd (patch) | |
tree | 79f66251286871397c898aca6ccb050c5f102f23 /server/sonar-web/src/main/js/components/common/__tests__ | |
parent | 7d546a463731e1410ba34225e2e1aa5d9586a3b2 (diff) | |
download | sonarqube-71cc0592365fc7ff36694c726c1a8ca4e1fcc6cd.tar.gz sonarqube-71cc0592365fc7ff36694c726c1a8ca4e1fcc6cd.zip |
SONAR-13880 internationalize tooltips
Diffstat (limited to 'server/sonar-web/src/main/js/components/common/__tests__')
2 files changed, 152 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/components/common/__tests__/DocumentationTooltip-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/DocumentationTooltip-test.tsx new file mode 100644 index 00000000000..fc7ae766eb8 --- /dev/null +++ b/server/sonar-web/src/main/js/components/common/__tests__/DocumentationTooltip-test.tsx @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * 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 * as React from 'react'; +import DocumentationTooltip, { DocumentationTooltipProps } from '../DocumentationTooltip'; + +it('renders correctly', () => { + expect(shallowRender()).toMatchSnapshot('basic'); + expect( + shallowRender({ + links: [ + { href: 'http://link.tosome.place', label: 'external link' }, + { href: '/documentation/guide', label: 'internal link' } + ] + }) + ).toMatchSnapshot('with links'); + expect(shallowRender({ title: undefined })).toMatchSnapshot('no title'); + expect(shallowRender({ content: undefined })).toMatchSnapshot('no content'); +}); + +function shallowRender(props: Partial<DocumentationTooltipProps> = {}) { + return shallow(<DocumentationTooltip content="content" title="title" {...props} />); +} diff --git a/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/DocumentationTooltip-test.tsx.snap b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/DocumentationTooltip-test.tsx.snap new file mode 100644 index 00000000000..423376fa2ce --- /dev/null +++ b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/DocumentationTooltip-test.tsx.snap @@ -0,0 +1,112 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly: basic 1`] = ` +<HelpTooltip + overlay={ + <div + className="big-padded-top big-padded-bottom" + > + <div + className="spacer-bottom" + > + <strong> + title + </strong> + </div> + <p> + content + </p> + </div> + } +/> +`; + +exports[`renders correctly: no content 1`] = ` +<HelpTooltip + overlay={ + <div + className="big-padded-top big-padded-bottom" + > + <div + className="spacer-bottom" + > + <strong> + title + </strong> + </div> + </div> + } +/> +`; + +exports[`renders correctly: no title 1`] = ` +<HelpTooltip + overlay={ + <div + className="big-padded-top big-padded-bottom" + > + <p> + content + </p> + </div> + } +/> +`; + +exports[`renders correctly: with links 1`] = ` +<HelpTooltip + overlay={ + <div + className="big-padded-top big-padded-bottom" + > + <div + className="spacer-bottom" + > + <strong> + title + </strong> + </div> + <p> + content + </p> + <React.Fragment> + <hr + className="big-spacer-top big-spacer-bottom" + /> + <div + className="little-spacer-bottom" + > + <a + className="display-inline-flex-center link-with-icon" + href="http://link.tosome.place" + rel="noopener noreferrer" + target="_blank" + > + <DetachIcon + className="spacer-right" + size={14} + /> + <span> + external link + </span> + </a> + </div> + <div + className="little-spacer-bottom" + > + <a + className="display-inline-flex-center link-with-icon" + href="/documentation/guide" + rel="noopener noreferrer" + target="_blank" + > + <span> + internal link + </span> + </a> + </div> + </React.Fragment> + </div> + } +/> +`; |