deployBadge.spec.tsx 1.4 KB

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