Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

PluginActions-test.tsx 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 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 * as React from 'react';
  21. import { shallow } from 'enzyme';
  22. import PluginActions from '../PluginActions';
  23. import { PluginInstalled, PluginAvailable } from '../../../../api/plugins';
  24. const installedPlugin: PluginInstalled = {
  25. key: 'foo',
  26. name: 'Foo',
  27. filename: 'foo.zip',
  28. hash: '',
  29. implementationBuild: '',
  30. sonarLintSupported: true,
  31. termsAndConditionsUrl: 'https://url',
  32. updatedAt: 1,
  33. updates: [{ status: 'COMPATIBLE', requires: [] }],
  34. version: '7.7'
  35. };
  36. const availablePlugin: PluginAvailable = {
  37. key: 'foo',
  38. name: 'Foo',
  39. release: { version: '7.7', date: 'date' },
  40. termsAndConditionsUrl: 'https://url',
  41. update: { status: 'COMPATIBLE', requires: [] }
  42. };
  43. it('should render installed plugin correctly', () => {
  44. expect(shallowRender()).toMatchSnapshot();
  45. expect(shallowRender({ plugin: { ...installedPlugin, editionBundled: true } })).toMatchSnapshot();
  46. });
  47. it('should render available plugin correctly', () => {
  48. expect(shallowRender({ plugin: availablePlugin })).toMatchSnapshot();
  49. expect(shallowRender({ plugin: { ...availablePlugin, editionBundled: true } })).toMatchSnapshot();
  50. });
  51. function shallowRender(props: Partial<PluginActions['props']> = {}) {
  52. return shallow(<PluginActions plugin={installedPlugin} refreshPending={jest.fn()} {...props} />);
  53. }