collapsePanel.spec.jsx 779 B

1234567891011121314151617181920212223242526
  1. import {Fragment} from 'react';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import CollapsePanel from 'sentry/components/collapsePanel';
  4. describe('CollapsePanel', () => {
  5. it('should expand on click', () => {
  6. render(
  7. <CollapsePanel items={10}>
  8. {({isExpanded, showMoreButton}) => (
  9. <Fragment>
  10. <div>expanded: {isExpanded.toString()}</div> {showMoreButton}
  11. </Fragment>
  12. )}
  13. </CollapsePanel>
  14. );
  15. expect(screen.getByText('expanded: false')).toBeInTheDocument();
  16. expect(screen.getByTestId('collapse-show-more')).toBeInTheDocument();
  17. userEvent.click(screen.getByTestId('collapse-show-more'));
  18. expect(screen.getByText('expanded: true')).toBeInTheDocument();
  19. });
  20. });