3 * Copyright (C) 2009-2023 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 { DEFAULT_GRAPH } from '../../../../components/activity-graph/utils';
23 import { parseDate } from '../../../../helpers/dates';
24 import ProjectActivityGraphs from '../ProjectActivityGraphs';
29 date: parseDate('2016-10-27T16:33:50+0200'),
30 events: [{ key: 'E1', category: 'VERSION', name: '6.5-SNAPSHOT' }],
34 date: parseDate('2016-10-27T12:21:15+0200'),
39 date: parseDate('2016-10-26T12:17:29+0200'),
41 { key: 'E2', category: 'VERSION', name: '6.4' },
42 { key: 'E3', category: 'OTHER', name: 'foo' },
47 const METRICS = [{ id: '1', key: 'code_smells', name: 'Code Smells', type: 'INT' }];
49 const DEFAULT_PROPS: ProjectActivityGraphs['props'] = {
51 leakPeriodDate: parseDate('2017-05-16T13:50:02+0200'),
55 metric: 'code_smells',
57 { date: parseDate('2016-10-26T12:17:29+0200'), value: '2286' },
58 { date: parseDate('2016-10-27T12:21:15+0200'), value: '1749' },
59 { date: parseDate('2016-10-27T16:33:50+0200'), value: '500' },
69 project: 'org.sonarsource.sonarqube:sonarqube',
71 updateQuery: () => {},
74 it('should render correctly the graph and legends', () => {
75 expect(shallow(<ProjectActivityGraphs {...DEFAULT_PROPS} />)).toMatchSnapshot();
78 it('should render correctly with filter history on dates', () => {
79 const wrapper = shallow(
80 <ProjectActivityGraphs
82 query={{ ...DEFAULT_PROPS.query, from: parseDate('2016-10-27T12:21:15+0200') }}
85 expect(wrapper.state()).toMatchSnapshot();