2
0

Layout.spec.tsx 717 B

1234567891011121314151617181920212223242526272829303132
  1. import { render, unmountComponentAtNode } from 'react-dom';
  2. import { act } from 'react-dom/test-utils';
  3. import Layout from '../../layout/Layout';
  4. let container: any = null;
  5. jest.mock('../../layout/GlobalEffect', () => {
  6. return () => {
  7. return <div id="global">{}</div>;
  8. };
  9. });
  10. describe('Test Layout', () => {
  11. beforeEach(() => {
  12. container = document.createElement('div');
  13. document.body.appendChild(container);
  14. });
  15. afterEach(() => {
  16. unmountComponentAtNode(container);
  17. container.remove();
  18. container = null;
  19. });
  20. it('Test Render', () => {
  21. act(() => {
  22. render(<Layout />, container);
  23. });
  24. expect(container.querySelectorAll('#global').length).toEqual(1);
  25. });
  26. });