/>
<React.Fragment>
foo
+ /
<React.Fragment>
<mark>
bar
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import { shallow } from 'enzyme';
+import * as React from 'react';
+import PluginUpdates, { PluginUpdatesProps } from '../components/PluginUpdates';
+
+it('should render correctly', () => {
+ expect(shallowRender()).toMatchSnapshot('default');
+ expect(
+ shallowRender({
+ updates: [
+ {
+ requires: [],
+ status: '',
+ release: { date: '2012-02-10', version: '1.3' }
+ },
+ {
+ requires: [],
+ status: '',
+ release: { date: '2012-02-01', version: '1.1' }
+ },
+ {
+ requires: [],
+ status: '',
+ release: { date: '2012-02-02', version: '1.2' }
+ }
+ ]
+ })
+ ).toMatchSnapshot('with status');
+});
+
+function shallowRender(props: Partial<PluginUpdatesProps> = {}) {
+ return shallow<PluginUpdatesProps>(<PluginUpdates {...props} />);
+}
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly: default 1`] = `""`;
+
+exports[`should render correctly: with status 1`] = `
+<li
+ className="spacer-top"
+>
+ <strong>
+ marketplace.updates
+ :
+ </strong>
+ <ul
+ className="little-spacer-top"
+ >
+ <PluginUpdateItem
+ key="1.3"
+ release={
+ Object {
+ "date": "2012-02-10",
+ "version": "1.3",
+ }
+ }
+ update={
+ Object {
+ "release": Object {
+ "date": "2012-02-10",
+ "version": "1.3",
+ },
+ "requires": Array [],
+ "status": "",
+ }
+ }
+ />
+ <PluginUpdateItem
+ key="1.1"
+ release={
+ Object {
+ "date": "2012-02-01",
+ "version": "1.1",
+ }
+ }
+ update={
+ Object {
+ "release": Object {
+ "date": "2012-02-01",
+ "version": "1.1",
+ },
+ "requires": Array [],
+ "status": "",
+ }
+ }
+ />
+ <PluginUpdateItem
+ key="1.2"
+ release={
+ Object {
+ "date": "2012-02-02",
+ "version": "1.2",
+ }
+ }
+ update={
+ Object {
+ "release": Object {
+ "date": "2012-02-02",
+ "version": "1.2",
+ },
+ "requires": Array [],
+ "status": "",
+ }
+ }
+ />
+ </ul>
+</li>
+`;
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { sortBy } from 'lodash';
import * as React from 'react';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { Release, Update } from '../../../types/plugins';
<h6>{translate('changelog')}</h6>
<ul className="js-plugin-changelog-list">
{update.previousUpdates &&
- update.previousUpdates.map(previousUpdate =>
+ sortBy(
+ update.previousUpdates,
+ prevUpdate => prevUpdate.release?.date
+ ).map(previousUpdate =>
previousUpdate.release ? (
<PluginChangeLogItem
key={previousUpdate.release.version}
import { Update } from '../../../types/plugins';
import PluginUpdateItem from './PluginUpdateItem';
-interface Props {
+export interface PluginUpdatesProps {
updates?: Update[];
}
-export default function PluginUpdates({ updates }: Props) {
+export default function PluginUpdates({ updates }: PluginUpdatesProps) {
if (!updates || updates.length <= 0) {
return null;
}
}}
update={{
previousUpdates: [
+ {
+ release: {
+ version: '0.11',
+ date: '2018-06-08',
+ description: 'Change version description',
+ changeLogUrl: 'https://my.change.log/url'
+ },
+ requires: [],
+ status: 'COMPATIBLE'
+ },
{
release: {
version: '0.10',
}
}
/>
+ <PluginChangeLogItem
+ key="0.11"
+ release={
+ Object {
+ "changeLogUrl": "https://my.change.log/url",
+ "date": "2018-06-08",
+ "description": "Change version description",
+ "version": "0.11",
+ }
+ }
+ update={
+ Object {
+ "release": Object {
+ "changeLogUrl": "https://my.change.log/url",
+ "date": "2018-06-08",
+ "description": "Change version description",
+ "version": "0.11",
+ },
+ "requires": Array [],
+ "status": "COMPATIBLE",
+ }
+ }
+ />
<PluginChangeLogItem
release={
Object {
update={
Object {
"previousUpdates": Array [
+ Object {
+ "release": Object {
+ "changeLogUrl": "https://my.change.log/url",
+ "date": "2018-06-08",
+ "description": "Change version description",
+ "version": "0.11",
+ },
+ "requires": Array [],
+ "status": "COMPATIBLE",
+ },
Object {
"release": Object {
"changeLogUrl": "https://my.change.log/url",