providerItem.spec.jsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  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. const wrapper = mountWithTheme(
  12. <ProviderItem organization={org} provider={provider} onConfigure={() => {}} />,
  13. routerContext
  14. );
  15. expect(wrapper.find('ProviderDescription').text()).toContain(
  16. 'Enable your organization to sign in with Dummy.'
  17. );
  18. expect(wrapper.find('Tag').exists()).toBe(false);
  19. });
  20. it('calls configure callback', function () {
  21. const mock = jest.fn();
  22. const wrapper = mountWithTheme(
  23. <ProviderItem organization={org} provider={provider} onConfigure={mock} />,
  24. routerContext
  25. );
  26. wrapper.find('Button').simulate('click');
  27. expect(mock).toHaveBeenCalledWith('dummy', expect.anything());
  28. });
  29. it('renders a disabled Tag when disabled', function () {
  30. const noFeatureRouterContext = TestStubs.routerContext();
  31. const wrapper = mountWithTheme(
  32. <ProviderItem organization={org} provider={provider} onConfigure={() => {}} />,
  33. noFeatureRouterContext
  34. );
  35. expect(wrapper.find('Tag').exists()).toBe(true);
  36. expect(wrapper.find('Tag').text()).toBe('disabled');
  37. });
  38. });