aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-profiles
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2019-03-29 18:39:32 +0100
committerSonarTech <sonartech@sonarsource.com>2019-04-04 20:21:04 +0200
commit2af145e34db52a865a16d36c85fb8d83a9cf1351 (patch)
tree0a907676728ff0d60b1c1275426929432bb8c118 /server/sonar-web/src/main/js/apps/quality-profiles
parentbddb35d5e638c63146846fbea96141d2f908c2b2 (diff)
downloadsonarqube-2af145e34db52a865a16d36c85fb8d83a9cf1351.tar.gz
sonarqube-2af145e34db52a865a16d36c85fb8d83a9cf1351.zip
Add some more coverage
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx56
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileProjects-test.tsx.snap95
2 files changed, 151 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx
new file mode 100644
index 00000000000..dcfdaabdb0e
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileProjects-test.tsx
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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 ProfileProjects from '../ProfileProjects';
+import { mockQualityProfile } from '../../../../helpers/testMocks';
+import { waitAndUpdate } from '../../../../helpers/testUtils';
+
+jest.mock('../../../../api/quality-profiles', () => ({
+ getProfileProjects: jest.fn().mockResolvedValue({
+ results: [
+ {
+ id: '633a5180-1ad7-4008-a5cb-e1d3cec4c816',
+ key: 'org.sonarsource.xml:xml',
+ name: 'SonarXML',
+ selected: true
+ }
+ ],
+ paging: { pageIndex: 1, pageSize: 2, total: 10 },
+ more: true
+ })
+}));
+
+it('should render correctly', async () => {
+ const wrapper = shallowRender();
+ expect(wrapper).toMatchSnapshot();
+ await waitAndUpdate(wrapper);
+ expect(wrapper).toMatchSnapshot();
+});
+
+function shallowRender(props: Partial<ProfileProjects['props']> = {}) {
+ return shallow(
+ <ProfileProjects
+ organization="foo"
+ profile={mockQualityProfile({ actions: { associateProjects: true } })}
+ {...props}
+ />
+ );
+}
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileProjects-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileProjects-test.tsx.snap
new file mode 100644
index 00000000000..de37df033c2
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileProjects-test.tsx.snap
@@ -0,0 +1,95 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly 1`] = `
+<div
+ className="boxed-group quality-profile-projects"
+>
+ <div
+ className="boxed-group-actions"
+ >
+ <Button
+ className="js-change-projects"
+ onClick={[Function]}
+ >
+ quality_profiles.change_projects
+ </Button>
+ </div>
+ <header
+ className="boxed-group-header"
+ >
+ <h2>
+ projects
+ </h2>
+ </header>
+ <div
+ className="boxed-group-inner"
+ >
+ <i
+ className="spinner"
+ />
+ </div>
+</div>
+`;
+
+exports[`should render correctly 2`] = `
+<div
+ className="boxed-group quality-profile-projects"
+>
+ <div
+ className="boxed-group-actions"
+ >
+ <Button
+ className="js-change-projects"
+ onClick={[Function]}
+ >
+ quality_profiles.change_projects
+ </Button>
+ </div>
+ <header
+ className="boxed-group-header"
+ >
+ <h2>
+ projects
+ </h2>
+ </header>
+ <div
+ className="boxed-group-inner"
+ >
+ <ul>
+ <li
+ className="spacer-top js-profile-project"
+ data-key="org.sonarsource.xml:xml"
+ key="org.sonarsource.xml:xml"
+ >
+ <Link
+ className="link-with-icon"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/dashboard",
+ "query": Object {
+ "id": "org.sonarsource.xml:xml",
+ },
+ }
+ }
+ >
+ <QualifierIcon
+ qualifier="TRK"
+ />
+
+ <span>
+ SonarXML
+ </span>
+ </Link>
+ </li>
+ </ul>
+ <ListFooter
+ count={1}
+ loadMore={[Function]}
+ ready={true}
+ total={10}
+ />
+ </div>
+</div>
+`;