This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// e.g. mockFetch({'avengers/me': {'name': "iron man", 'rank': 2}}) | |
function mockFetch(urlResponseMap) { | |
window.fetchOriginal = window.fetch | |
window.fetch = (...params) => { | |
const lookFor = Object.keys(urlResponseMap); | |
const url = typeof params[0] == 'object' ? params[0].url : params[0]; |