diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-10-13 15:45:56 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-10-23 08:01:13 -0700 |
commit | cc7c40ced053d5ba7bcc453b28f9cfcdf022a180 (patch) | |
tree | ca98a5f3358225b843f361dabd57cfd7fe940f43 /server/sonar-web/src | |
parent | d04f3466ac7eda479ddd559e8b245eff971c6ee2 (diff) | |
download | sonarqube-cc7c40ced053d5ba7bcc453b28f9cfcdf022a180.tar.gz sonarqube-cc7c40ced053d5ba7bcc453b28f9cfcdf022a180.zip |
SONAR-9935 Add some unit tests
Diffstat (limited to 'server/sonar-web/src')
25 files changed, 485 insertions, 33 deletions
diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx index 0e51d154342..df07149f700 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import PluginAvailable from './PluginAvailable'; -import PluginInstalled from './PluginInstalled'; +import PluginAvailable from './components/PluginAvailable'; +import PluginInstalled from './components/PluginInstalled'; import { isPluginAvailable, isPluginInstalled, Query } from './utils'; import { Plugin, PluginPending } from '../../api/plugins'; diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/Footer-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/__tests__/Footer-test.tsx new file mode 100644 index 00000000000..58e9f4b8390 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/Footer-test.tsx @@ -0,0 +1,26 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import Footer from '../Footer'; + +it('should display the number of plugins', () => { + expect(shallow(<Footer total={3} />)).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/PendingActions-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/__tests__/PendingActions-test.tsx new file mode 100644 index 00000000000..9d9d15c3bf8 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/PendingActions-test.tsx @@ -0,0 +1,94 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import { click } from '../../../helpers/testUtils'; +import PendingActions from '../PendingActions'; + +jest.mock('../../../api/plugins', () => ({ + cancelPendingPlugins: jest.fn(() => Promise.resolve()) +})); + +const cancelPendingPlugins = require('../../../api/plugins').cancelPendingPlugins as jest.Mock<any>; + +beforeEach(() => { + cancelPendingPlugins.mockClear(); +}); + +it('should display pending actions', () => { + expect(getWrapper()).toMatchSnapshot(); +}); + +it('should not display nothing', () => { + expect(getWrapper({ pending: { installing: [], updating: [], removing: [] } })).toMatchSnapshot(); +}); + +it('should open the restart form', () => { + const wrapper = getWrapper(); + click(wrapper.find('.js-restart')); + expect(wrapper.find('RestartForm')).toHaveLength(1); +}); + +it('should cancel all pending and refresh them', async () => { + const refreshPending = jest.fn(); + const wrapper = getWrapper({ refreshPending }); + click(wrapper.find('.js-cancel-all')); + expect(cancelPendingPlugins).toHaveBeenCalled(); + await new Promise(setImmediate); + + expect(refreshPending).toHaveBeenCalled(); +}); + +function getWrapper(props = {}) { + return shallow( + <PendingActions + pending={{ + installing: [ + { + key: 'foo', + name: 'Foo', + description: 'foo description', + version: 'fooversion', + implementationBuild: 'foobuild' + }, + { + key: 'bar', + name: 'Bar', + description: 'bar description', + version: 'barversion', + implementationBuild: 'barbuild' + } + ], + updating: [], + removing: [ + { + key: 'baz', + name: 'Baz', + description: 'baz description', + version: 'bazversion', + implementationBuild: 'bazbuild' + } + ] + }} + refreshPending={() => {}} + {...props} + /> + ); +} diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/Footer-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/Footer-test.tsx.snap new file mode 100644 index 00000000000..164d3bd00e6 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/Footer-test.tsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display the number of plugins 1`] = ` +<footer + className="spacer-top note text-center" +> + x_show.3 +</footer> +`; diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/PendingActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/PendingActions-test.tsx.snap new file mode 100644 index 00000000000..36604e80f98 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/PendingActions-test.tsx.snap @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display pending actions 1`] = ` +<div + className="js-pending panel panel-warning big-spacer-bottom" +> + <div + className="display-inline-block" + > + <p> + marketplace.sonarqube_needs_to_be_restarted_to + </p> + <ul + className="list-styled spacer-top" + > + <li> + <FormattedMessage + defaultMessage="marketplace.install_x_plugins" + id="marketplace.install_x_plugins" + values={ + Object { + "nb": <strong + className="text-success big little-spacer-left little-spacer-right" + > + 2 + </strong>, + } + } + /> + </li> + <li> + <FormattedMessage + defaultMessage="marketplace.uninstall_x_plugins" + id="marketplace.uninstall_x_plugins" + values={ + Object { + "nb": <strong + className="text-danger big little-spacer-left little-spacer-right" + > + 1 + </strong>, + } + } + /> + </li> + </ul> + </div> + <div + className="pull-right button-group" + > + <button + className="js-restart" + onClick={[Function]} + > + marketplace.restart + </button> + <button + className="js-cancel-all button-red" + onClick={[Function]} + > + marketplace.revert + </button> + </div> +</div> +`; + +exports[`should not display nothing 1`] = `null`; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginActions.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginActions.tsx index f2fce9f658e..f2fce9f658e 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginActions.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginActions.tsx diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginAvailable.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginAvailable.tsx index c80f5969e62..a6badc50eab 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginAvailable.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginAvailable.tsx @@ -24,9 +24,9 @@ import PluginLicense from './PluginLicense'; import PluginOrganization from './PluginOrganization'; import PluginStatus from './PluginStatus'; import PluginUrls from './PluginUrls'; -import { PluginAvailable } from '../../api/plugins'; -import { translateWithParameters } from '../../helpers/l10n'; -import { Query } from './utils'; +import { PluginAvailable } from '../../../api/plugins'; +import { translateWithParameters } from '../../../helpers/l10n'; +import { Query } from '../utils'; interface Props { plugin: PluginAvailable; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLog.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginChangeLog.tsx index 21690e4e136..8bf0eb63ccf 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLog.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginChangeLog.tsx @@ -18,10 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import BubblePopup from '../../components/common/BubblePopup'; +import BubblePopup from '../../../components/common/BubblePopup'; import PluginChangeLogItem from './PluginChangeLogItem'; -import { Release, Update } from '../../api/plugins'; -import { translate } from '../../helpers/l10n'; +import { Release, Update } from '../../../api/plugins'; +import { translate } from '../../../helpers/l10n'; interface Props { popupPosition?: any; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogButton.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginChangeLogButton.tsx index 61b309cb291..45269e4e220 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogButton.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginChangeLogButton.tsx @@ -18,9 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import BubblePopupHelper from '../../components/common/BubblePopupHelper'; +import BubblePopupHelper from '../../../components/common/BubblePopupHelper'; import PluginChangeLog from './PluginChangeLog'; -import { Release, Update } from '../../api/plugins'; +import { Release, Update } from '../../../api/plugins'; interface Props { release: Release; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogItem.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginChangeLogItem.tsx index 163c8165ced..5093609838c 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogItem.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginChangeLogItem.tsx @@ -18,10 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import DateFormatter from '../../components/intl/DateFormatter'; -import Tooltip from '../../components/controls/Tooltip'; -import { Release, Update } from '../../api/plugins'; -import { translate, translateWithParameters } from '../../helpers/l10n'; +import DateFormatter from '../../../components/intl/DateFormatter'; +import Tooltip from '../../../components/controls/Tooltip'; +import { Release, Update } from '../../../api/plugins'; +import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { release: Release; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginDescription.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginDescription.tsx index 8de1f3b0476..9ee5b5d53b7 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginDescription.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginDescription.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Plugin } from '../../api/plugins'; -import { Query } from './utils'; +import { Plugin } from '../../../api/plugins'; +import { Query } from '../utils'; interface Props { plugin: Plugin; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginInstalled.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginInstalled.tsx index b9225f3820e..6dc69081d72 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginInstalled.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginInstalled.tsx @@ -24,9 +24,9 @@ import PluginOrganization from './PluginOrganization'; import PluginStatus from './PluginStatus'; import PluginUpdates from './PluginUpdates'; import PluginUrls from './PluginUrls'; -import { PluginInstalled } from '../../api/plugins'; -import { translate } from '../../helpers/l10n'; -import { Query } from './utils'; +import { PluginInstalled } from '../../../api/plugins'; +import { translate } from '../../../helpers/l10n'; +import { Query } from '../utils'; interface Props { plugin: PluginInstalled; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginLicense.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginLicense.tsx index 550ba9249f3..0ee76f8637d 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginLicense.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginLicense.tsx @@ -19,7 +19,7 @@ */ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; -import { translate } from '../../helpers/l10n'; +import { translate } from '../../../helpers/l10n'; interface Props { license?: string; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginOrganization.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginOrganization.tsx index 505ebd16f28..e992630c8ba 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginOrganization.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginOrganization.tsx @@ -19,8 +19,8 @@ */ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; -import { translate } from '../../helpers/l10n'; -import { Plugin } from '../../api/plugins'; +import { translate } from '../../../helpers/l10n'; +import { Plugin } from '../../../api/plugins'; interface Props { plugin: Plugin; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginStatus.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginStatus.tsx index 298206f2e92..d797cbbd736 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginStatus.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginStatus.tsx @@ -18,9 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Plugin } from '../../api/plugins'; +import { Plugin } from '../../../api/plugins'; import PluginActions from './PluginActions'; -import { translate } from '../../helpers/l10n'; +import { translate } from '../../../helpers/l10n'; interface Props { plugin: Plugin; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginUpdateButton.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginUpdateButton.tsx index 53c154e8fa6..41028a6ff0a 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginUpdateButton.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginUpdateButton.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Update } from '../../api/plugins'; -import { translateWithParameters } from '../../helpers/l10n'; +import { Update } from '../../../api/plugins'; +import { translateWithParameters } from '../../../helpers/l10n'; interface Props { disabled: boolean; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginUpdateItem.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginUpdateItem.tsx index ea5d581362d..453ab2741b0 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginUpdateItem.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginUpdateItem.tsx @@ -19,9 +19,9 @@ */ import * as React from 'react'; import PluginChangeLogButton from './PluginChangeLogButton'; -import Tooltip from '../../components/controls/Tooltip'; -import { Release, Update } from '../../api/plugins'; -import { translate } from '../../helpers/l10n'; +import Tooltip from '../../../components/controls/Tooltip'; +import { Release, Update } from '../../../api/plugins'; +import { translate } from '../../../helpers/l10n'; interface Props { update: Update; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginUpdates.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginUpdates.tsx index b662651f1dc..805495bc041 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginUpdates.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginUpdates.tsx @@ -19,8 +19,8 @@ */ import * as React from 'react'; import PluginUpdateItem from './PluginUpdateItem'; -import { Update } from '../../api/plugins'; -import { translate } from '../../helpers/l10n'; +import { Update } from '../../../api/plugins'; +import { translate } from '../../../helpers/l10n'; interface Props { updates?: Update[]; diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginUrls.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/PluginUrls.tsx index adcdd816168..576b8911f90 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginUrls.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/PluginUrls.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Plugin } from '../../api/plugins'; -import { translate } from '../../helpers/l10n'; +import { Plugin } from '../../../api/plugins'; +import { translate } from '../../../helpers/l10n'; interface Props { plugin: Plugin; diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginDescription-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginDescription-test.tsx new file mode 100644 index 00000000000..0b525f21b58 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginDescription-test.tsx @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import { click } from '../../../../helpers/testUtils'; +import PluginDescription from '../PluginDescription'; + +it('should display the description and category', () => { + expect(getWrapper()).toMatchSnapshot(); +}); + +it('should not display any category', () => { + expect( + getWrapper({ plugin: { key: 'foo', name: 'Foo', description: 'foo description' } }) + ).toMatchSnapshot(); +}); + +it('should update query when clicking on category', () => { + const updateQuery = jest.fn(); + const wrapper = getWrapper({ updateQuery }); + click(wrapper.find('.js-plugin-category')); + expect(updateQuery).toHaveBeenCalledWith({ search: 'foocategory' }); +}); + +function getWrapper(props = {}) { + return shallow( + <PluginDescription + plugin={{ + key: 'foo', + name: 'Foo', + description: 'foo description', + category: 'foocategory' + }} + updateQuery={() => {}} + {...props} + /> + ); +} diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginLicense-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginLicense-test.tsx new file mode 100644 index 00000000000..1031b90b53b --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginLicense-test.tsx @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import PluginLicense from '../PluginLicense'; + +it('should display the license field', () => { + expect(shallow(<PluginLicense license="SonarSource license" />)).toMatchSnapshot(); +}); + +it('should not display anything', () => { + expect(shallow(<PluginLicense />)).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginUrls-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginUrls-test.tsx new file mode 100644 index 00000000000..cbddc53a91f --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/PluginUrls-test.tsx @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import PluginUrls from '../PluginUrls'; + +it('should display the urls', () => { + expect(getWrapper()).toMatchSnapshot(); +}); + +it('should display only one url', () => { + expect(getWrapper({ issueTrackerUrl: undefined })).toMatchSnapshot(); +}); + +it('should not display anything', () => { + expect(getWrapper({ homepageUrl: undefined, issueTrackerUrl: undefined })).toMatchSnapshot(); +}); + +function getWrapper(plugin = {}) { + return shallow( + <PluginUrls + plugin={{ + key: 'foo', + name: 'Foo', + description: 'foo description', + homepageUrl: 'homepageurl', + issueTrackerUrl: 'issuetrackerurl', + ...plugin + }} + /> + ); +} diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginDescription-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginDescription-test.tsx.snap new file mode 100644 index 00000000000..6120da38dc8 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginDescription-test.tsx.snap @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display the description and category 1`] = ` +<td + className="text-top width-20 big-spacer-right" +> + <div> + <strong + className="js-plugin-name" + > + Foo + </strong> + <a + className="js-plugin-category badge spacer-left" + href="#" + onClick={[Function]} + > + foocategory + </a> + </div> + <div + className="js-plugin-description little-spacer-top" + > + foo description + </div> +</td> +`; + +exports[`should not display any category 1`] = ` +<td + className="text-top width-20 big-spacer-right" +> + <div> + <strong + className="js-plugin-name" + > + Foo + </strong> + </div> + <div + className="js-plugin-description little-spacer-top" + > + foo description + </div> +</td> +`; diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginLicense-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginLicense-test.tsx.snap new file mode 100644 index 00000000000..f37ffec7f02 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginLicense-test.tsx.snap @@ -0,0 +1,24 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display the license field 1`] = ` +<li + className="little-spacer-bottom text-limited" + title="SonarSource license" +> + <FormattedMessage + defaultMessage="marketplace.licensed_under_x" + id="marketplace.licensed_under_x" + values={ + Object { + "license": <span + className="js-plugin-license" + > + SonarSource license + </span>, + } + } + /> +</li> +`; + +exports[`should not display anything 1`] = `null`; diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginUrls-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginUrls-test.tsx.snap new file mode 100644 index 00000000000..f1a088480ba --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/PluginUrls-test.tsx.snap @@ -0,0 +1,52 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display only one url 1`] = ` +<li + className="little-spacer-bottom" +> + <ul + className="list-inline" + > + <li> + <a + className="js-plugin-homepage" + href="homepageurl" + target="_blank" + > + marketplace.homepage + </a> + </li> + </ul> +</li> +`; + +exports[`should display the urls 1`] = ` +<li + className="little-spacer-bottom" +> + <ul + className="list-inline" + > + <li> + <a + className="js-plugin-homepage" + href="homepageurl" + target="_blank" + > + marketplace.homepage + </a> + </li> + <li> + <a + className="js-plugin-issues" + href="issuetrackerurl" + target="_blank" + > + marketplace.issue_tracker + </a> + </li> + </ul> +</li> +`; + +exports[`should not display anything 1`] = `null`; |