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';
23 import { DEFAULT_GRAPH } from '../../utils';
28 date: '2016-10-27T16:33:50+0200',
39 date: '2016-10-27T12:21:15+0200',
44 date: '2016-10-26T12:17:29+0200',
60 const METRICS = [{ key: 'code_smells', name: 'Code Smells', type: 'INT' }];
62 const DEFAULT_PROPS = {
64 leakPeriodDate: '2017-05-16T13:50:02+0200',
68 metric: 'code_smells',
70 { date: new Date('2016-10-26T12:17:29+0200'), value: '2286' },
71 { date: new Date('2016-10-27T12:21:15+0200'), value: '1749' },
72 { date: new Date('2016-10-27T16:33:50+0200'), value: '500' }
77 query: { category: '', graph: DEFAULT_GRAPH, project: 'org.sonarsource.sonarqube:sonarqube' },
81 it('should render correctly the graph and legends', () => {
82 expect(shallow(<ProjectActivityGraphs {...DEFAULT_PROPS} />)).toMatchSnapshot();
85 it('should render correctly with filter history on dates', () => {
86 const wrapper = shallow(
87 <ProjectActivityGraphs
89 query={{ ...DEFAULT_PROPS.query, from: '2016-10-27T12:21:15+0200' }}
92 expect(wrapper.state()).toMatchSnapshot();