"use strict" ; type Json = { [ key ] : unknown ; } ; type MockResponse = { status : number ; statusText : string ; ok : boolean ; body : Json ; } ; let mockResponses = { } ; const defaultMockResponseParams = { status : 200 , statusText : "OK" , ok : true , } ; export default async function fetch ( url ) { const mockResponse = mockResponses [ url ] ; if ( mockResponse ) { const fullMockResponse = { ... defaultMockResponseParams , ... mockResponse } ; return { status : fullMockResponse . status , statusText : fullMockResponse . statusText , ok : fullMockResponse . ok , json : ( ) => Promise . resolve ( fullMockResponse . body ) , } ; } throw new Error ( `Unknown URL: ${ url }` ) ; } export function __setMockResponses ( newMockResponses ) { mockResponses = newMockResponses ; } export function __resetMockResponses ( ) { __setMockResponses ( { } ) ; }