projectPlugins.spec.jsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import ProjectPlugins from 'app/views/settings/projectPlugins/projectPlugins';
  3. describe('ProjectPlugins', function () {
  4. let wrapper;
  5. const routerContext = TestStubs.routerContext();
  6. const plugins = TestStubs.Plugins();
  7. const org = TestStubs.Organization();
  8. const project = TestStubs.Project();
  9. const params = {
  10. orgId: org.slug,
  11. projectId: project.slug,
  12. };
  13. it('renders', function () {
  14. wrapper = mountWithTheme(
  15. <ProjectPlugins params={params} plugins={plugins} />,
  16. routerContext
  17. );
  18. expect(wrapper).toSnapshot();
  19. });
  20. it('has loading state', function () {
  21. wrapper = mountWithTheme(
  22. <ProjectPlugins params={params} loading plugins={[]} />,
  23. routerContext
  24. );
  25. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  26. });
  27. it('has error state when plugins=null and loading is true', function () {
  28. wrapper = mountWithTheme(
  29. <ProjectPlugins
  30. params={params}
  31. plugins={null}
  32. loading
  33. error={new Error('An error')}
  34. />,
  35. routerContext
  36. );
  37. expect(wrapper.find('RouteError')).toHaveLength(1);
  38. });
  39. it('has error state when plugins=[]', function () {
  40. wrapper = mountWithTheme(
  41. <ProjectPlugins
  42. params={params}
  43. plugins={[]}
  44. loading
  45. error={new Error('An error')}
  46. />,
  47. routerContext
  48. );
  49. expect(wrapper.find('RouteError')).toHaveLength(1);
  50. });
  51. });