providerItem.spec.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {AuthProvidersFixture} from 'sentry-fixture/authProviders';
  2. import {OrganizationFixture} 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 = AuthProvidersFixture()[0];
  8. const org = OrganizationFixture({
  9. features: [descopeFeatureName(provider.requiredFeature)],
  10. });
  11. it('renders', function () {
  12. render(<ProviderItem active={false} provider={provider} onConfigure={() => {}} />, {
  13. organization: org,
  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. organization: org,
  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. render(<ProviderItem active={false} provider={provider} onConfigure={() => {}} />, {
  29. organization: OrganizationFixture(),
  30. });
  31. expect(screen.getByRole('status')).toHaveTextContent('disabled');
  32. });
  33. });