deployBadge.spec.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import DeployBadge from 'sentry/components/deployBadge';
  3. import type {Deploy} from 'sentry/types';
  4. const deploy: Deploy = {
  5. name: '85fedddce5a61a58b160fa6b3d6a1a8451e94eb9 to prod',
  6. url: '',
  7. environment: 'production',
  8. dateStarted: '2020-05-11T18:12:00.025928Z',
  9. dateFinished: '2020-05-11T18:12:00.025928Z',
  10. version: '4.2.0',
  11. id: '6348842',
  12. };
  13. describe('DeployBadge', () => {
  14. it('renders', () => {
  15. render(<DeployBadge deploy={deploy} />);
  16. expect(screen.getByText('production')).toBeInTheDocument();
  17. expect(screen.queryByRole('link')).not.toBeInTheDocument();
  18. expect(screen.queryByTestId('deploy-open-icon')).not.toBeInTheDocument();
  19. });
  20. it('renders with icon and link', () => {
  21. const projectId = 1;
  22. render(
  23. <DeployBadge
  24. deploy={deploy}
  25. orgSlug="sentry"
  26. version="1.2.3"
  27. projectId={projectId}
  28. />,
  29. {context: TestStubs.routerContext()}
  30. );
  31. expect(screen.queryByRole('link')).toHaveAttribute(
  32. 'href',
  33. `/organizations/sentry/issues/?environment=${deploy.environment}&project=${projectId}&query=release%3A1.2.3`
  34. );
  35. expect(screen.getByText('production')).toBeInTheDocument();
  36. expect(screen.getByTestId('deploy-open-icon')).toBeInTheDocument();
  37. });
  38. });