loadingContainer.spec.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import LoadingContainer from 'app/components/loading/loadingContainer';
  4. describe('LoadingContainer', function() {
  5. let wrapper;
  6. beforeEach(() => {
  7. wrapper = mount(
  8. <LoadingContainer>
  9. <div>hello!</div>
  10. </LoadingContainer>
  11. );
  12. });
  13. it('handles normal state', () => {
  14. expect(wrapper.text()).toBe('hello!');
  15. expect(wrapper.find('LoadingIndicator')).toHaveLength(0);
  16. });
  17. it('handles loading state', () => {
  18. wrapper.setProps({isLoading: true});
  19. expect(wrapper.text()).toBe('hello!');
  20. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  21. wrapper.setProps({children: null});
  22. expect(wrapper.text()).toBe('');
  23. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  24. });
  25. it('handles reloading state', () => {
  26. wrapper.setProps({isReloading: true});
  27. expect(wrapper.text()).toBe('hello!');
  28. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  29. wrapper.setProps({children: null});
  30. expect(wrapper.text()).toBe('');
  31. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  32. });
  33. });