From: Stas Vilchik Date: Thu, 21 Jun 2018 19:31:55 +0000 (+0200) Subject: SONARCLOUD-52 display logo correctly (#428) X-Git-Tag: 7.5~937 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a928388df7f0072d1aa8f2b315a380aa175c4d61;p=sonarqube.git SONARCLOUD-52 display logo correctly (#428) --- diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx index c3241fc8643..7d2fb58fb66 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx @@ -49,13 +49,13 @@ interface OwnProps { type Props = StateProps & OwnProps; -class GlobalNav extends React.PureComponent { +export class GlobalNav extends React.PureComponent { static contextTypes = { openProjectOnboarding: PropTypes.func }; render() { return ( - {isSonarCloud ? : } + {isSonarCloud() ? : } diff --git a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNav-test.tsx b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNav-test.tsx new file mode 100644 index 00000000000..17ed417200a --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNav-test.tsx @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import { GlobalNav } from '../GlobalNav'; +import { isSonarCloud } from '../../../../../helpers/system'; + +jest.mock('../../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); + +const appState = { qualifiers: [] }; +const currentUser = { isLoggedIn: false }; +const location = { pathname: '' }; + +it('should render for SonarQube', () => { + runTest(false); +}); + +it('should render for SonarCloud', () => { + runTest(true); +}); + +function runTest(mockedIsSonarCloud: boolean) { + (isSonarCloud as jest.Mock).mockImplementation(() => mockedIsSonarCloud); + expect( + shallow( + + ) + ).toMatchSnapshot(); +} diff --git a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap new file mode 100644 index 00000000000..c1733d6b202 --- /dev/null +++ b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap @@ -0,0 +1,150 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render for SonarCloud 1`] = ` + + + +
    + + + + +
+
+`; + +exports[`should render for SonarQube 1`] = ` + + + +
    + + + +
+
+`;