providerItem.spec.tsx 1.5 KB

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