providerItem.spec.tsx 1.5 KB

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