organizationProjects.spec.jsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import {Client} from 'app/api';
  4. import OrganizationProjectsViewContainer from 'app/views/settings/organization/projects/organizationProjectsView';
  5. describe('OrganizationProjectsView', function() {
  6. let org;
  7. let project;
  8. let projectsGetMock;
  9. let statsGetMock;
  10. let projectsPutMock;
  11. beforeEach(function() {
  12. project = TestStubs.Project();
  13. org = TestStubs.Organization();
  14. projectsGetMock = Client.addMockResponse({
  15. url: '/organizations/org-slug/projects/',
  16. body: [project],
  17. });
  18. statsGetMock = Client.addMockResponse({
  19. url: '/organizations/org-slug/stats/',
  20. body: [[[], 1]],
  21. });
  22. projectsPutMock = Client.addMockResponse({
  23. method: 'PUT',
  24. url: '/projects/org-slug/project-slug/',
  25. });
  26. });
  27. afterEach(function() {
  28. Client.clearMockResponses();
  29. });
  30. describe('render()', function() {
  31. it('Should render the projects in the store', function() {
  32. let wrapper = mount(
  33. <OrganizationProjectsViewContainer params={{orgId: org.slug}} />,
  34. TestStubs.routerOrganizationContext()
  35. );
  36. expect(wrapper).toMatchSnapshot();
  37. expect(wrapper.find('.project-name').text()).toBe('Project Name');
  38. expect(projectsGetMock).toHaveBeenCalledTimes(1);
  39. expect(statsGetMock).toHaveBeenCalledTimes(1);
  40. expect(projectsPutMock).toHaveBeenCalledTimes(0);
  41. wrapper.find('.icon-star-outline').simulate('click');
  42. expect(wrapper.find('.icon-star-solid')).toBeTruthy();
  43. expect(projectsPutMock).toHaveBeenCalledTimes(1);
  44. });
  45. });
  46. });