platformSelector.spec.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {browserHistory} from 'sentry/utils/browserHistory';
  3. import localStorage from 'sentry/utils/localStorage';
  4. import {PlatformSelector} from 'sentry/views/insights/mobile/screenload/components/platformSelector';
  5. jest.mock('sentry/utils/localStorage');
  6. describe('PlatformSelector', function () {
  7. it('renders with iOS and Android options', function () {
  8. render(<PlatformSelector />);
  9. expect(screen.getByRole('radiogroup', {name: 'Filter platform'})).toBeInTheDocument();
  10. expect(screen.getByRole('radio', {name: 'Android'})).toBeChecked();
  11. expect(screen.getByRole('radio', {name: 'iOS'})).not.toBeChecked();
  12. });
  13. it('updates url params on click', async function () {
  14. render(<PlatformSelector />);
  15. await userEvent.click(screen.getByRole('radio', {name: 'iOS'}));
  16. expect(browserHistory.push).toHaveBeenCalledWith({
  17. pathname: '/mock-pathname/',
  18. query: {
  19. platform: 'iOS',
  20. screensCursor: undefined,
  21. },
  22. });
  23. expect(localStorage.setItem).toHaveBeenCalledWith(
  24. 'mobile-performance-platform',
  25. 'iOS'
  26. );
  27. });
  28. });