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';
23 mockAlmSettingsBindingStatus,
24 mockAzureBindingDefinition,
25 mockGithubBindingDefinition
26 } from '../../../../../helpers/mocks/alm-settings';
27 import { AlmKeys, AlmSettingsBindingStatusType } from '../../../../../types/alm-settings';
28 import AlmBindingDefinitionBox, { AlmBindingDefinitionBoxProps } from '../AlmBindingDefinitionBox';
30 it('should render correctly', () => {
31 expect(shallowRender()).toMatchSnapshot('default');
32 expect(shallowRender({ multipleDefinitions: true })).toMatchSnapshot('multiple definitions');
35 status: mockAlmSettingsBindingStatus({
36 type: AlmSettingsBindingStatusType.Success
39 ).toMatchSnapshot('success');
42 status: mockAlmSettingsBindingStatus({
43 failureMessage: 'Oops, something went wrong',
44 type: AlmSettingsBindingStatusType.Failure
47 ).toMatchSnapshot('error');
51 status: mockAlmSettingsBindingStatus({
53 type: AlmSettingsBindingStatusType.Success
56 ).toMatchSnapshot('success with alert');
60 status: mockAlmSettingsBindingStatus({
61 type: AlmSettingsBindingStatusType.Warning
64 ).toMatchSnapshot('warning');
67 shallowRender({ alm: AlmKeys.Azure, definition: mockAzureBindingDefinition() })
68 ).toMatchSnapshot('Azure DevOps');
71 function shallowRender(props: Partial<AlmBindingDefinitionBoxProps> = {}) {
73 <AlmBindingDefinitionBox
75 definition={mockGithubBindingDefinition()}
76 multipleDefinitions={false}