providerItem.spec.tsx 1.4 KB

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