providerItem.spec.jsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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(
  12. <ProviderItem organization={org} 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', function () {
  20. const mock = jest.fn();
  21. render(<ProviderItem organization={org} provider={provider} onConfigure={mock} />, {
  22. context: routerContext,
  23. });
  24. 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(
  30. <ProviderItem organization={org} provider={provider} onConfigure={() => {}} />,
  31. {context: noFeatureRouterContext}
  32. );
  33. expect(screen.getByRole('status')).toHaveTextContent('disabled');
  34. });
  35. });