projectPlugins.spec.jsx 1.4 KB

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