]> source.dussan.org Git - sonarqube.git/commitdiff
SONARCLOUD-52 display logo correctly (#428)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 21 Jun 2018 19:31:55 +0000 (21:31 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 29 Jun 2018 07:10:10 +0000 (09:10 +0200)
server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx
server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNav-test.tsx [new file with mode: 0644]
server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap [new file with mode: 0644]

index c3241fc86431a9f35adea3cd34f08b1376bffe2f..7d2fb58fb663284dedf67e0a0b5d3b8af9c0d5b5 100644 (file)
@@ -49,13 +49,13 @@ interface OwnProps {
 
 type Props = StateProps & OwnProps;
 
-class GlobalNav extends React.PureComponent<Props> {
+export class GlobalNav extends React.PureComponent<Props> {
   static contextTypes = { openProjectOnboarding: PropTypes.func };
 
   render() {
     return (
       <NavBar className="navbar-global" height={theme.globalNavHeightRaw} id="global-navigation">
-        {isSonarCloud ? <SonarCloudNavBranding /> : <GlobalNavBranding />}
+        {isSonarCloud() ? <SonarCloudNavBranding /> : <GlobalNavBranding />}
 
         <GlobalNavMenu {...this.props} />
 
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 (file)
index 0000000..17ed417
--- /dev/null
@@ -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(
+      <GlobalNav
+        appState={appState}
+        currentUser={currentUser}
+        location={location}
+        suggestions={[]}
+      />
+    )
+  ).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 (file)
index 0000000..c1733d6
--- /dev/null
@@ -0,0 +1,150 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render for SonarCloud 1`] = `
+<NavBar
+  className="navbar-global"
+  height={48}
+  id="global-navigation"
+>
+  <SonarCloudNavBranding />
+  <GlobalNavMenu
+    appState={
+      Object {
+        "qualifiers": Array [],
+      }
+    }
+    currentUser={
+      Object {
+        "isLoggedIn": false,
+      }
+    }
+    location={
+      Object {
+        "pathname": "",
+      }
+    }
+    suggestions={Array []}
+  />
+  <ul
+    className="global-navbar-menu pull-right"
+  >
+    <GlobalNavExplore
+      location={
+        Object {
+          "pathname": "",
+        }
+      }
+    />
+    <EmbedDocsPopupHelper
+      currentUser={
+        Object {
+          "isLoggedIn": false,
+        }
+      }
+      suggestions={Array []}
+      tooltip={false}
+    />
+    <Search
+      appState={
+        Object {
+          "qualifiers": Array [],
+        }
+      }
+      currentUser={
+        Object {
+          "isLoggedIn": false,
+        }
+      }
+    />
+    <Connect(GlobalNavUser)
+      appState={
+        Object {
+          "qualifiers": Array [],
+        }
+      }
+      currentUser={
+        Object {
+          "isLoggedIn": false,
+        }
+      }
+      location={
+        Object {
+          "pathname": "",
+        }
+      }
+      suggestions={Array []}
+    />
+  </ul>
+</NavBar>
+`;
+
+exports[`should render for SonarQube 1`] = `
+<NavBar
+  className="navbar-global"
+  height={48}
+  id="global-navigation"
+>
+  <Connect(GlobalNavBranding) />
+  <GlobalNavMenu
+    appState={
+      Object {
+        "qualifiers": Array [],
+      }
+    }
+    currentUser={
+      Object {
+        "isLoggedIn": false,
+      }
+    }
+    location={
+      Object {
+        "pathname": "",
+      }
+    }
+    suggestions={Array []}
+  />
+  <ul
+    className="global-navbar-menu pull-right"
+  >
+    <EmbedDocsPopupHelper
+      currentUser={
+        Object {
+          "isLoggedIn": false,
+        }
+      }
+      suggestions={Array []}
+      tooltip={true}
+    />
+    <Search
+      appState={
+        Object {
+          "qualifiers": Array [],
+        }
+      }
+      currentUser={
+        Object {
+          "isLoggedIn": false,
+        }
+      }
+    />
+    <Connect(GlobalNavUser)
+      appState={
+        Object {
+          "qualifiers": Array [],
+        }
+      }
+      currentUser={
+        Object {
+          "isLoggedIn": false,
+        }
+      }
+      location={
+        Object {
+          "pathname": "",
+        }
+      }
+      suggestions={Array []}
+    />
+  </ul>
+</NavBar>
+`;