providerItem.spec.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. });
  17. expect(
  18. screen.getByText('Enable your organization to sign in with Dummy.')
  19. ).toBeInTheDocument();
  20. });
  21. it('calls configure callback', async function () {
  22. const mock = jest.fn();
  23. render(<ProviderItem active={false} provider={provider} onConfigure={mock} />, {
  24. context: routerContext,
  25. });
  26. await userEvent.click(screen.getByRole('button', {name: 'Configure'}));
  27. expect(mock).toHaveBeenCalledWith('dummy', expect.anything());
  28. });
  29. it('renders a disabled Tag when disabled', function () {
  30. const noFeatureRouterContext = RouterContextFixture();
  31. render(<ProviderItem active={false} provider={provider} onConfigure={() => {}} />, {
  32. context: noFeatureRouterContext,
  33. });
  34. expect(screen.getByRole('status')).toHaveTextContent('disabled');
  35. });
  36. });