3 * Copyright (C) 2009-2022 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';
23 mockAlmSettingsBindingStatus,
24 mockAzureBindingDefinition,
25 mockBitbucketCloudBindingDefinition,
26 mockGithubBindingDefinition,
27 mockGitlabBindingDefinition,
28 } from '../../../../../helpers/mocks/alm-settings';
29 import { AlmKeys, AlmSettingsBindingStatusType } from '../../../../../types/alm-settings';
30 import AlmBindingDefinitionBox, { AlmBindingDefinitionBoxProps } from '../AlmBindingDefinitionBox';
32 it('should render correctly', () => {
33 expect(shallowRender()).toMatchSnapshot('default');
34 expect(shallowRender({ multipleDefinitions: true })).toMatchSnapshot('multiple definitions');
37 status: mockAlmSettingsBindingStatus({
38 type: AlmSettingsBindingStatusType.Success,
41 ).toMatchSnapshot('success');
44 status: mockAlmSettingsBindingStatus({
45 failureMessage: 'Oops, something went wrong',
46 type: AlmSettingsBindingStatusType.Failure,
49 ).toMatchSnapshot('error');
53 status: mockAlmSettingsBindingStatus({
55 type: AlmSettingsBindingStatusType.Success,
58 ).toMatchSnapshot('success with alert');
62 status: mockAlmSettingsBindingStatus({
63 type: AlmSettingsBindingStatusType.Warning,
66 ).toMatchSnapshot('warning');
69 shallowRender({ alm: AlmKeys.Azure, definition: mockAzureBindingDefinition() })
70 ).toMatchSnapshot('Azure DevOps');
74 status: mockAlmSettingsBindingStatus({
75 type: AlmSettingsBindingStatusType.Success,
78 definition: mockGitlabBindingDefinition(),
80 ).toMatchSnapshot('success for GitLab');
84 status: mockAlmSettingsBindingStatus({
85 type: AlmSettingsBindingStatusType.Success,
87 alm: AlmKeys.BitbucketCloud,
88 definition: mockBitbucketCloudBindingDefinition(),
90 ).toMatchSnapshot('success for Bitbucket Cloud');
94 branchesEnabled: false,
95 status: mockAlmSettingsBindingStatus({
97 type: AlmSettingsBindingStatusType.Success,
100 ).toMatchSnapshot('success with branches disabled');
103 function shallowRender(props: Partial<AlmBindingDefinitionBoxProps> = {}) {
105 <AlmBindingDefinitionBox
107 branchesEnabled={true}
108 definition={mockGithubBindingDefinition()}
109 multipleDefinitions={false}