1import { List } from './';
2import React from 'react';
3import '@testing-library/jest-dom/extend-expect';
4import { render, waitForElement } from '@testing-library/react';
5
6describe('59892259', () => {
7 let originFetch;
8 beforeEach(() => {
9 originFetch = (global as any).fetch;
10 });
11 afterEach(() => {
12 (global as any).fetch = originFetch;
13 });
14 it('should pass', async () => {
15 const fakeResponse = { title: 'example text' };
16 const mRes = { json: jest.fn().mockResolvedValueOnce(fakeResponse) };
17 const mockedFetch = jest.fn().mockResolvedValueOnce(mRes as any);
18 (global as any).fetch = mockedFetch;
19 const { getByTestId } = render(<List></List>);
20 const div = await waitForElement(() => getByTestId('test'));
21 expect(div).toHaveTextContent('example text');
22 expect(mockedFetch).toBeCalledTimes(1);
23 expect(mRes.json).toBeCalledTimes(1);
24 });
25});
26