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} />
--- /dev/null
+/*
+ * 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();
+}
--- /dev/null
+// 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>
+`;