3 * Copyright (C) 2009-2020 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 { AlmKeys } from '../../../../../types/alm-settings';
23 import AlmBindingDefinitionsTable, {
24 AlmBindingDefinitionsTableProps
25 } from '../AlmBindingDefinitionsTable';
27 it('should render correctly', () => {
28 expect(shallowRender()).toMatchSnapshot();
31 additionalColumnsHeaders: ['additional1', 'additional2'],
34 { key: 'definition1', additionalColumns: ['def1-v1', 'def1-v2'] },
35 { key: 'definition2', additionalColumns: ['def2-v1', 'def2-v2'] }
38 ).toMatchSnapshot('additional columns');
39 expect(shallowRender({ alm: AlmKeys.GitLab })).toMatchSnapshot('title adjusts for GitLab');
42 it('should correctly trigger create, delete, and edit', () => {
43 const onCreate = jest.fn();
44 const onDelete = jest.fn();
45 const onEdit = jest.fn();
47 const wrapper = shallowRender({
48 additionalColumnsHeaders: [],
49 alm: AlmKeys.Bitbucket,
50 definitions: [{ key: 'defKey', additionalColumns: [] }],
56 wrapper.find('Button').simulate('click');
57 expect(onCreate).toBeCalled();
59 wrapper.find('DeleteButton').simulate('click');
60 expect(onDelete).toBeCalledWith('defKey');
62 wrapper.find('ButtonIcon').simulate('click');
63 expect(onEdit).toBeCalledWith('defKey');
66 function shallowRender(props: Partial<AlmBindingDefinitionsTableProps> = {}) {
68 <AlmBindingDefinitionsTable
69 additionalColumnsHeaders={[]}