withProjects.spec.jsx 774 B

12345678910111213141516171819202122232425262728
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import ProjectsStore from 'app/stores/projectsStore';
  4. import withProjects from 'app/utils/withProjects';
  5. describe('withProjects HoC', function() {
  6. beforeEach(() => {
  7. ProjectsStore.reset();
  8. });
  9. it('works', function() {
  10. const MyComponent = () => null;
  11. let Container = withProjects(MyComponent);
  12. let wrapper = mount(<Container />);
  13. expect(wrapper.find('MyComponent').prop('projects')).toEqual([]);
  14. // Insert into projects store
  15. let project = TestStubs.Project();
  16. ProjectsStore.loadInitialData([project]);
  17. wrapper.update();
  18. let props = wrapper.find('MyComponent').prop('projects');
  19. expect(props).toHaveLength(1);
  20. expect(props[0].id).toBe(project.id);
  21. });
  22. });