1it('should display message retrieved with ajax request',
2 async (done) => {
3 const fakePromise = Promise.resolve(mockResponse(
4 200,
5 null,
6 JSON.stringify({message: message})
7 ));
8 window.fetch = jest.fn().mockImplementationOnce(() => {
9 return fakePromise
10 });
11 expect.assertions(2); //check if all assertions called
12 const info = mount(<Info infoUrl = {url} />);
13 await Promise.all([fakePromise]);
14 setImmediate(() => {
15 try {
16 expect(info).toHaveState('message', message);
17 expect(info).toIncludeText(message);
18 } catch (e) {
19 done.fail(e);
20 }
21 done();
22 });
23 });
24