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 { DEFAULT_GRAPH } from '../../utils';
28 date: new Date('2016-10-27T16:33:50+0000'),
39 date: new Date('2016-10-27T12:21:15+0000'),
44 date: new Date('2016-10-26T12:17:29+0000'),
60 date: new Date('2016-10-24T16:33:50+0000'),
64 category: 'QUALITY_GATE',
65 name: 'Quality gate changed to red...'
71 const DEFAULT_PROPS = {
72 addCustomEvent: () => {},
75 analysesLoading: false,
77 changeEvent: () => {},
78 deleteAnalysis: () => {},
79 deleteEvent: () => {},
81 project: { qualifier: 'TRK' },
82 query: { category: '', graph: DEFAULT_GRAPH, project: 'org.sonarsource.sonarqube:sonarqube' },
86 jest.mock('moment', () => date => ({
89 valueOf: () => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`
92 toDate: () => new Date(date),
93 format: format => `Formated.${format}:${date}`
96 window.Number = val => val;
98 it('should render correctly', () => {
99 expect(shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />)).toMatchSnapshot();
102 it('should correctly filter analyses by category', () => {
103 const wrapper = shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />);
104 wrapper.setProps({ query: { ...DEFAULT_PROPS.query, category: 'QUALITY_GATE' } });
105 expect(wrapper).toMatchSnapshot();
108 it('should correctly filter analyses by date range', () => {
109 const wrapper = shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />);
112 ...DEFAULT_PROPS.query,
113 from: new Date('2016-10-27T16:33:50+0000'),
114 to: new Date('2016-10-27T16:33:50+0000')
117 expect(wrapper).toMatchSnapshot();