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 RenderCommandForClangOrGCC,
24 RenderCommandForGradle,
25 RenderCommandForMaven,
27 } from '../AnalysisCommandCustom';
28 import { ProjectAnalysisModes } from '../../ProjectAnalysisStepFromBuildTool';
29 import { mockComponent, mockLoggedInUser } from '../../../../../helpers/testMocks';
31 const organization = 'org';
34 it('should render for Clang or GCC', () => {
35 expect(shallowRender('make')).toMatchSnapshot();
38 it('should render for Gradle', () => {
39 expect(shallowRender('gradle')).toMatchSnapshot();
42 it('should render for Maven', () => {
43 expect(shallowRender('maven')).toMatchSnapshot();
46 it('should render for other', () => {
47 expect(shallowRender('other')).toMatchSnapshot();
50 it('should render for unsupported build systems', () => {
51 expect(shallowRender('whatever')).toMatchSnapshot();
54 it('should render RenderCommandForClangOrGCC', () => {
55 const render = (token?: string) =>
57 <RenderCommandForClangOrGCC
58 currentUser={mockLoggedInUser()}
59 mode={ProjectAnalysisModes.Custom}
61 toggleModal={jest.fn()}
66 expect(render()).toMatchSnapshot();
67 expect(render('123')).toMatchSnapshot();
70 it('should render RenderCommandForGradle', () => {
71 const render = (token?: string) =>
73 <RenderCommandForGradle
74 currentUser={mockLoggedInUser()}
75 mode={ProjectAnalysisModes.Custom}
77 toggleModal={jest.fn()}
82 expect(render()).toMatchSnapshot();
83 expect(render('123')).toMatchSnapshot();
86 it('should render RenderCommandForMaven', () => {
87 const render = (token?: string) =>
89 <RenderCommandForMaven
90 currentUser={mockLoggedInUser()}
91 mode={ProjectAnalysisModes.Custom}
93 toggleModal={jest.fn()}
98 expect(render()).toMatchSnapshot();
99 expect(render('123')).toMatchSnapshot();
102 it('should render RenderCommandForOther', () => {
103 const render = (token?: string) =>
105 <RenderCommandForOther
106 currentUser={mockLoggedInUser()}
107 mode={ProjectAnalysisModes.Custom}
109 toggleModal={jest.fn()}
114 expect(render()).toMatchSnapshot();
115 expect(render('123')).toMatchSnapshot();
118 function shallowRender(buildType: string) {
120 <AnalysisCommandTravis
121 buildType={buildType}
122 component={mockComponent()}
123 currentUser={mockLoggedInUser()}
124 mode={ProjectAnalysisModes.Custom}
126 organization={organization}