Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ComponentReportActionsRenderer-test.tsx 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2022 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 { mockComponent } from '../../../helpers/mocks/component';
  23. import { ComponentQualifier } from '../../../types/component';
  24. import ComponentReportActionsRenderer, {
  25. ComponentReportActionsRendererProps
  26. } from '../ComponentReportActionsRenderer';
  27. it('should render correctly', () => {
  28. expect(shallowRender({ canSubscribe: false })).toMatchSnapshot('cannot subscribe');
  29. expect(shallowRender({ canSubscribe: true, subscribed: false })).toMatchSnapshot(
  30. 'can subscribe, not subscribed'
  31. );
  32. expect(shallowRender({ canSubscribe: true, subscribed: true })).toMatchSnapshot(
  33. 'can subscribe, subscribed'
  34. );
  35. expect(shallowRender({ canSubscribe: true, currentUserHasEmail: false })).toMatchSnapshot(
  36. 'current user without email'
  37. );
  38. expect(shallowRender({ component: mockComponent() })).toMatchSnapshot('not a portfolio');
  39. });
  40. function shallowRender(props: Partial<ComponentReportActionsRendererProps> = {}) {
  41. return shallow<ComponentReportActionsRendererProps>(
  42. <ComponentReportActionsRenderer
  43. component={mockComponent({ qualifier: ComponentQualifier.Portfolio })}
  44. canSubscribe={true}
  45. subscribed={false}
  46. currentUserHasEmail={true}
  47. frequency="weekly"
  48. handleSubscription={jest.fn()}
  49. handleUnsubscription={jest.fn()}
  50. {...props}
  51. />
  52. );
  53. }