1import { APISettings } from '../../settings'; 2import { wrapFetchWithOffline } from '../wrapFetchWithOffline'; 3 4jest.mock('../../settings', () => ({ 5 APISettings: { 6 isOffline: true, 7 }, 8})); 9 10describe(wrapFetchWithOffline, () => { 11 it(`supports normal requests`, async () => { 12 APISettings.isOffline = false; 13 const input = jest.fn(); 14 const next = wrapFetchWithOffline(input); 15 await next('https://example.com/', {}); 16 expect(input).toBeCalledWith('https://example.com/', {}); 17 }); 18 it(`times out instantly when offline`, async () => { 19 APISettings.isOffline = true; 20 const input = jest.fn(); 21 const next = wrapFetchWithOffline(input); 22 await next('https://example.com/', {}); 23 expect(input).toBeCalledWith('https://example.com/', { timeout: 1 }); 24 }); 25}); 26