arrayLinks.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {ArrayLinks} from 'sentry/components/profiling/arrayLinks';
  3. describe('ArrayLinks', function () {
  4. it('renders single item', function () {
  5. render(<ArrayLinks items={[{target: '/foo', value: 'foo'}]} />);
  6. expect(screen.getByText('foo')).toBeInTheDocument();
  7. });
  8. it('renders two items', function () {
  9. render(
  10. <ArrayLinks
  11. items={[
  12. {target: '/foo', value: 'foo'},
  13. {target: '/bar', value: 'bar'},
  14. ]}
  15. />
  16. );
  17. expect(screen.getByText('foo')).toBeInTheDocument();
  18. expect(screen.queryByText('bar')).not.toBeInTheDocument();
  19. expect(screen.getByText('[+1 more]')).toBeInTheDocument();
  20. expect(screen.queryByText('[collapse]')).not.toBeInTheDocument();
  21. userEvent.click(screen.getByText('[+1 more]'));
  22. expect(screen.getByText('foo')).toBeInTheDocument();
  23. expect(screen.getByText('bar')).toBeInTheDocument();
  24. expect(screen.queryByText('[+1 more]')).not.toBeInTheDocument();
  25. expect(screen.getByText('[collapse]')).toBeInTheDocument();
  26. userEvent.click(screen.getByText('[collapse]'));
  27. expect(screen.getByText('foo')).toBeInTheDocument();
  28. expect(screen.queryByText('bar')).not.toBeInTheDocument();
  29. expect(screen.getByText('[+1 more]')).toBeInTheDocument();
  30. expect(screen.queryByText('[collapse]')).not.toBeInTheDocument();
  31. });
  32. });