3 * Copyright (C) 2009-2021 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 { shallow } from 'enzyme';
21 import * as React from 'react';
22 import { mockMainBranch } from '../../../../../../helpers/mocks/branch-like';
23 import { mockComponent } from '../../../../../../helpers/testMocks';
24 import { ComponentQualifier } from '../../../../../../types/component';
25 import { CurrentBranchLike, CurrentBranchLikeProps } from '../CurrentBranchLike';
27 describe('CurrentBranchLikeRenderer should render correctly for application when', () => {
28 it('there is only one branch and the user can admin the application', () => {
29 const wrapper = shallowRender({
30 component: mockComponent({
31 configuration: { showSettings: true },
32 qualifier: ComponentQualifier.Application
34 hasManyBranches: false
36 expect(wrapper).toMatchSnapshot();
39 it("there is only one branch and the user CAN'T admin the application", () => {
40 const wrapper = shallowRender({
41 component: mockComponent({
42 configuration: { showSettings: false },
43 qualifier: ComponentQualifier.Application
45 hasManyBranches: false
47 expect(wrapper).toMatchSnapshot();
50 it('there are many branchlikes', () => {
51 const wrapper = shallowRender({
52 branchesEnabled: true,
53 component: mockComponent({
54 qualifier: ComponentQualifier.Application
58 expect(wrapper).toMatchSnapshot();
62 describe('CurrentBranchLikeRenderer should render correctly for project when', () => {
63 it('branches support is disabled', () => {
64 const wrapper = shallowRender({
65 branchesEnabled: false,
66 component: mockComponent({
67 qualifier: ComponentQualifier.Project
70 expect(wrapper).toMatchSnapshot();
73 it('there is only one branchlike', () => {
74 const wrapper = shallowRender({
75 branchesEnabled: true,
76 component: mockComponent({
77 qualifier: ComponentQualifier.Project
79 hasManyBranches: false
81 expect(wrapper).toMatchSnapshot();
84 it('there are many branchlikes', () => {
85 const wrapper = shallowRender({
86 branchesEnabled: true,
87 component: mockComponent({
88 qualifier: ComponentQualifier.Project
92 expect(wrapper).toMatchSnapshot();
96 function shallowRender(props?: Partial<CurrentBranchLikeProps>) {
99 branchesEnabled={false}
100 component={mockComponent()}
101 currentBranchLike={mockMainBranch()}
102 hasManyBranches={false}