radioPanelGroup.spec.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import RadioGroupPanel from 'sentry/views/alerts/wizard/radioPanelGroup';
  3. describe('RadioGroupPanel', function () {
  4. it('calls onChange when clicked', function () {
  5. const mock = jest.fn();
  6. render(
  7. <RadioGroupPanel
  8. label="test"
  9. value="choice_one"
  10. choices={[
  11. ['choice_one', 'Choice One'],
  12. ['choice_two', 'Choice Two'],
  13. ['choice_three', 'Choice Three'],
  14. ]}
  15. onChange={mock}
  16. />
  17. );
  18. userEvent.click(screen.getByText('Choice Three'));
  19. expect(mock).toHaveBeenCalledWith(expect.any(String), expect.any(Object));
  20. });
  21. it('Renders extra content', function () {
  22. const mock = jest.fn();
  23. render(
  24. <RadioGroupPanel
  25. label="test"
  26. value="choice_one"
  27. choices={[
  28. ['choice_one', 'Choice One'],
  29. ['choice_two', 'Choice Two', 'extra content'],
  30. ['choice_three', 'Choice Three'],
  31. ]}
  32. onChange={mock}
  33. />
  34. );
  35. expect(screen.getByText('extra content')).toBeInTheDocument();
  36. });
  37. });