1/* eslint-env jest browser */
2import { fetchAsync } from '../fetchAsync';
3
4declare const global: any;
5
6const originalFetch = global.fetch;
7
8beforeAll(() => {
9  // eslint-disable-next-line
10  global.fetch = jest.fn(() =>
11    // eslint-disable-next-line
12    Promise.resolve({ body: "", text: jest.fn(() => "mock"), headers: {} })
13  );
14});
15
16afterAll(() => {
17  global.fetch = originalFetch;
18});
19
20it(`fetches`, async () => {
21  await expect(fetchAsync('https://example.com')).resolves.toBeDefined();
22  expect(global.fetch).toBeCalledWith('https://example.com', {
23    headers: { 'expo-platform': 'web' },
24    method: 'GET',
25  });
26});
27