providerItem.spec.jsx 1.5 KB

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