platformList.spec.jsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import PlatformList from 'sentry/components/platformList';
  3. describe('PlatformList', function () {
  4. const platforms = ['java', 'php', 'javascript', 'cocoa', 'ruby'];
  5. it('renders max of three icons from platforms', function () {
  6. render(<PlatformList platforms={platforms} />);
  7. expect(screen.getAllByRole('img')).toHaveLength(3);
  8. });
  9. it('renders default if no platforms', function () {
  10. render(<PlatformList platforms={[]} />);
  11. expect(screen.getByRole('img')).toBeInTheDocument();
  12. });
  13. it('displays counter', async function () {
  14. render(<PlatformList platforms={platforms} showCounter />);
  15. const icons = screen.getAllByRole('img');
  16. expect(icons).toHaveLength(3);
  17. // Check tooltip content,
  18. const extra = screen.getByText('2');
  19. userEvent.hover(extra);
  20. expect(await screen.findByText('2 other platforms')).toBeInTheDocument();
  21. });
  22. it('displays counter according to the max value', function () {
  23. const max = 2;
  24. render(<PlatformList platforms={platforms} max={max} showCounter />);
  25. const icons = screen.getAllByRole('img');
  26. expect(icons).toHaveLength(max);
  27. const extraCounter = platforms.length - max;
  28. expect(screen.getByText(extraCounter)).toBeInTheDocument();
  29. });
  30. });