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 ProjectActivityAnalysesList from '../ProjectActivityAnalysesList';
23 import * as dates from '../../../../helpers/dates';
24 import { DEFAULT_GRAPH } from '../../utils';
29 date: new Date('2016-10-27T16:33:50+0000'),
40 date: new Date('2016-10-27T12:21:15+0000'),
45 date: new Date('2016-10-26T12:17:29+0000'),
61 date: new Date('2016-10-24T16:33:50+0000'),
65 category: 'QUALITY_GATE',
66 name: 'Quality gate changed to red...'
72 const DEFAULT_PROPS = {
73 addCustomEvent: () => {},
76 analysesLoading: false,
78 changeEvent: () => {},
79 deleteAnalysis: () => {},
80 deleteEvent: () => {},
82 project: { qualifier: 'TRK' },
83 query: { category: '', graph: DEFAULT_GRAPH, project: 'org.sonarsource.sonarqube:sonarqube' },
87 window.Number = val => val;
89 dates.startOfDay = jest.fn(date => {
90 const startDay = new Date(date);
91 startDay.setUTCHours(0, 0, 0, 0);
95 it('should render correctly', () => {
96 expect(shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />)).toMatchSnapshot();
99 it('should correctly filter analyses by category', () => {
100 const wrapper = shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />);
101 wrapper.setProps({ query: { ...DEFAULT_PROPS.query, category: 'QUALITY_GATE' } });
102 expect(wrapper).toMatchSnapshot();
105 it('should correctly filter analyses by date range', () => {
106 const wrapper = shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />);
109 ...DEFAULT_PROPS.query,
110 from: new Date('2016-10-27T16:33:50+0000'),
111 to: new Date('2016-10-27T16:33:50+0000')
114 expect(wrapper).toMatchSnapshot();