3 * Copyright (C) 2009-2017 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 React from 'react';
21 import { shallow } from 'enzyme';
22 import ProjectActivityGraphs from '../ProjectActivityGraphs';
27 date: '2016-10-27T16:33:50+0200',
38 date: '2016-10-27T12:21:15+0200',
43 date: '2016-10-26T12:17:29+0200',
59 const METRICS = [{ key: 'code_smells', name: 'Code Smells', type: 'INT' }];
61 const DEFAULT_PROPS = {
63 leakPeriodDate: '2017-05-16T13:50:02+0200',
67 metric: 'code_smells',
69 { date: new Date('2016-10-26T12:17:29+0200'), value: '2286' },
70 { date: new Date('2016-10-27T12:21:15+0200'), value: '1749' },
71 { date: new Date('2016-10-27T16:33:50+0200'), value: '500' }
76 query: { category: '', graph: 'overview', project: 'org.sonarsource.sonarqube:sonarqube' },
80 it('should render correctly the graph and legends', () => {
81 expect(shallow(<ProjectActivityGraphs {...DEFAULT_PROPS} />)).toMatchSnapshot();
84 it('should render correctly with filter history on dates', () => {
85 const wrapper = shallow(
86 <ProjectActivityGraphs
88 query={{ ...DEFAULT_PROPS.query, from: '2016-10-27T12:21:15+0200' }}
91 expect(wrapper.state()).toMatchSnapshot();
94 it('should show a loading view instead of the graph', () => {
96 shallow(<ProjectActivityGraphs {...DEFAULT_PROPS} loading={true} />).find('.spinner')
100 it('should show that there is no history data', () => {
103 <ProjectActivityGraphs
105 measuresHistory={[{ metric: 'code_smells', history: [] }]}
111 <ProjectActivityGraphs
115 metric: 'code_smells',
116 history: [{ date: new Date('2016-10-26T12:17:29+0200'), value: undefined }]
122 project: 'org.sonarsource.sonarqube:sonarqube',
123 customMetrics: ['code_smells']