Created
January 8, 2018 15:02
-
-
Save daneov/4140862bac9dc5b1445607935004651e to your computer and use it in GitHub Desktop.
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
function mockWithType(contentType, httpMethod = "GET", referenceUrl = "/") { | |
const urlResult = baseUrl + referenceUrl | |
console.log("Mocked '" + urlResult + "' for " + httpMethod); | |
fetchMock.mock( | |
(url, opts) => { | |
return url === urlResult && opts && opts.headers && opts.headers.get('Content-Type') === contentType | |
}, | |
{ | |
number: 200, | |
body: {} | |
}, | |
{ | |
method: httpMethod | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment