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';
27 date: new Date('2016-10-27T16:33:50+0000'),
38 date: new Date('2016-10-27T12:21:15+0000'),
43 date: new Date('2016-10-26T12:17:29+0000'),
59 date: new Date('2016-10-24T16:33:50+0000'),
63 category: 'QUALITY_GATE',
64 name: 'Quality gate changed to red...'
70 const DEFAULT_PROPS = {
71 addCustomEvent: () => {},
74 analysesLoading: false,
76 changeEvent: () => {},
77 deleteAnalysis: () => {},
78 deleteEvent: () => {},
80 query: { category: '', graph: 'overview', project: 'org.sonarsource.sonarqube:sonarqube' },
84 jest.mock('moment', () => date => ({
87 valueOf: () => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`
90 toDate: () => new Date(date),
91 format: format => `Formated.${format}:${date}`
94 window.Number = val => val;
96 it('should render correctly', () => {
97 expect(shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />)).toMatchSnapshot();
100 it('should correctly filter analyses by category', () => {
101 const wrapper = shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />);
102 wrapper.setProps({ query: { ...DEFAULT_PROPS.query, category: 'QUALITY_GATE' } });
103 expect(wrapper).toMatchSnapshot();
106 it('should correctly filter analyses by date range', () => {
107 const wrapper = shallow(<ProjectActivityAnalysesList {...DEFAULT_PROPS} />);
110 ...DEFAULT_PROPS.query,
111 from: new Date('2016-10-27T16:33:50+0000'),
112 to: new Date('2016-10-27T16:33:50+0000')
115 expect(wrapper).toMatchSnapshot();