loadingContainer.spec.jsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {cleanup, mountWithTheme} from 'sentry-test/reactTestingLibrary';
  2. import LoadingContainer from 'app/components/loading/loadingContainer';
  3. function renderComponent(props) {
  4. return mountWithTheme(
  5. <LoadingContainer {...props}>
  6. <div>hello!</div>
  7. </LoadingContainer>
  8. );
  9. }
  10. describe('LoadingContainer', () => {
  11. afterEach(cleanup);
  12. it('handles normal state', () => {
  13. const {getByText, getByTestId} = renderComponent();
  14. expect(getByText('hello!')).toBeTruthy();
  15. expect(() => getByTestId('loading-indicator')).toThrow();
  16. });
  17. it('handles loading state', () => {
  18. const {getByTestId, getByText, rerender, queryByText} = renderComponent({
  19. isLoading: true,
  20. });
  21. expect(getByText('hello!')).toBeTruthy();
  22. expect(getByTestId('loading-indicator')).toBeTruthy();
  23. rerender(<LoadingContainer isLoading />);
  24. expect(queryByText('hello!')).toBeNull();
  25. expect(getByTestId('loading-indicator')).toBeTruthy();
  26. });
  27. it('handles reloading state', () => {
  28. const {getByTestId, getByText, rerender, queryByText} = renderComponent({
  29. isReloading: true,
  30. });
  31. expect(getByText('hello!')).toBeTruthy();
  32. expect(getByTestId('loading-indicator')).toBeTruthy();
  33. rerender(<LoadingContainer isReloading />);
  34. expect(queryByText('hello!')).toBeNull();
  35. expect(getByTestId('loading-indicator')).toBeTruthy();
  36. });
  37. });