providerItem.spec.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {AuthProvidersFixture} from 'sentry-fixture/authProviders';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
  4. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  5. import {descopeFeatureName} from 'sentry/utils';
  6. import ProviderItem from 'sentry/views/settings/organizationAuth/providerItem';
  7. describe('ProviderItem', function () {
  8. const provider = AuthProvidersFixture()[0];
  9. const org = OrganizationFixture({
  10. features: [descopeFeatureName(provider.requiredFeature)],
  11. });
  12. const routerContext = RouterContextFixture([{organization: org}]);
  13. it('renders', function () {
  14. render(<ProviderItem active={false} provider={provider} onConfigure={() => {}} />, {
  15. context: routerContext,
  16. organization: org,
  17. });
  18. expect(
  19. screen.getByText('Enable your organization to sign in with Dummy.')
  20. ).toBeInTheDocument();
  21. });
  22. it('calls configure callback', async function () {
  23. const mock = jest.fn();
  24. render(<ProviderItem active={false} provider={provider} onConfigure={mock} />, {
  25. context: routerContext,
  26. organization: org,
  27. });
  28. await userEvent.click(screen.getByRole('button', {name: 'Configure'}));
  29. expect(mock).toHaveBeenCalledWith('dummy', expect.anything());
  30. });
  31. it('renders a disabled Tag when disabled', function () {
  32. render(<ProviderItem active={false} provider={provider} onConfigure={() => {}} />, {
  33. context: RouterContextFixture(),
  34. organization: OrganizationFixture(),
  35. });
  36. expect(screen.getByRole('status')).toHaveTextContent('disabled');
  37. });
  38. });