3 * Copyright (C) 2009-2019 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 import * as React from 'react';
21 import { shallow } from 'enzyme';
22 import AnalysisCommandTravis, {
23 getSonarcloudAddonYml,
24 getSonarcloudAddonYmlRender,
25 RenderCommandForClangOrGCC,
26 RenderCommandForGradle,
27 RenderCommandForMaven,
28 RenderCommandForOther,
31 } from '../AnalysisCommandTravis';
35 analysisDate: '2016-01-01',
43 const organization = 'org';
46 it('should render for Clang or GCC', () => {
49 .find(RenderCommandForClangOrGCC)
54 it('should render for Gradle', () => {
56 shallowRender('gradle')
57 .find(RenderCommandForGradle)
62 it('should render for Maven', () => {
64 shallowRender('maven')
65 .find(RenderCommandForMaven)
70 it('should render for other', () => {
72 shallowRender('other')
73 .find(RenderCommandForOther)
78 it('should render nothing for unsupported build', () => {
81 .find(RenderCommandForOther)
86 shallowRender('anotherBuild')
87 .find(RenderCommandForOther)
92 it('should render nothing when there is no project key', () => {
93 expect(shallow(<RenderCommandForClangOrGCC />).html()).toBe(null);
94 expect(shallow(<RenderCommandForGradle />).html()).toBe(null);
95 expect(shallow(<RenderCommandForMaven />).html()).toBe(null);
96 expect(shallow(<RenderCommandForOther />).html()).toBe(null);
99 it('should render the sonarcloud yaml for travis', () => {
100 expect(getSonarcloudAddonYml()).toMatchSnapshot();
101 expect(getSonarcloudAddonYml('SonarSource')).toMatchSnapshot();
104 it('should render the sonarcloud yaml for travis', () => {
105 expect(getSonarcloudAddonYmlRender()).toMatchSnapshot();
106 expect(getSonarcloudAddonYmlRender('SonarSource')).toMatchSnapshot();
109 it('should render the requirements for builds', () => {
110 expect(shallow(<RequirementJavaBuild />)).toMatchSnapshot();
111 expect(shallow(<RequirementOtherBuild />)).toMatchSnapshot();
114 function shallowRender(buildType?: string) {
116 <AnalysisCommandTravis
117 buildType={buildType}
118 component={component}
119 organization={organization}