]> source.dussan.org Git - sonarqube.git/blob
6b775f034dfca18104dfb033daf5529afd936574
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2021 SonarSource SA
4  * mailto:info AT sonarsource DOT com
5  *
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.
10  *
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.
15  *
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.
19  */
20 import { shallow } from 'enzyme';
21 import * as React from 'react';
22 import { EditionKey } from '../../../../../types/editions';
23 import SystemUpgradeItem, { SystemUpgradeItemProps } from '../SystemUpgradeItem';
24
25 it('should display correctly', () => {
26   expect(shallowRender()).toMatchSnapshot();
27   expect(shallowRender({ isLatestVersion: false })).toMatchSnapshot();
28   expect(shallowRender({ edition: EditionKey.developer })).toMatchSnapshot();
29   expect(shallowRender({ edition: EditionKey.enterprise })).toMatchSnapshot();
30   expect(shallowRender({ edition: EditionKey.datacenter })).toMatchSnapshot();
31   // Fallback to Community.
32   expect(
33     shallowRender({
34       systemUpgrades: [
35         {
36           version: '5.6.7',
37           description: 'Version 5.6.7 description',
38           releaseDate: '2017-03-01',
39           changeLogUrl: 'http://changelog.url/',
40           downloadUrl: 'http://download.url/community'
41         }
42       ]
43     })
44   ).toMatchSnapshot();
45 });
46
47 function shallowRender(props: Partial<SystemUpgradeItemProps> = {}) {
48   return shallow<SystemUpgradeItemProps>(
49     <SystemUpgradeItem
50       edition={EditionKey.community}
51       systemUpgrades={[
52         {
53           version: '5.6.7',
54           description: 'Version 5.6.7 description',
55           releaseDate: '2017-03-01',
56           changeLogUrl: 'http://changelog.url/',
57           downloadUrl: 'http://download.url/community',
58           downloadDeveloperUrl: 'http://download.url/developer',
59           downloadEnterpriseUrl: 'http://download.url/enterprise',
60           downloadDatacenterUrl: 'http://download.url/datacenter'
61         },
62         {
63           version: '5.6.6',
64           description: 'Version 5.6.6 description',
65           releaseDate: '2017-04-02',
66           changeLogUrl: 'http://changelog.url/',
67           downloadUrl: 'http://download.url/community',
68           downloadDeveloperUrl: 'http://download.url/developer'
69         },
70         {
71           version: '5.6.5',
72           description: 'Version 5.6.5 description',
73           releaseDate: '2017-03-01',
74           changeLogUrl: 'http://changelog.url/',
75           downloadUrl: 'http://download.url/community',
76           downloadDeveloperUrl: 'http://download.url/developer'
77         }
78       ]}
79       isLatestVersion={true}
80       {...props}
81     />
82   );
83 }