Created
October 2, 2016 14:38
-
-
Save coder36/a5c6f37623a066e50bbe52dd258b77f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import sinonStubPromise from 'sinon-stub-promise'; | |
import sinon from 'sinon' | |
sinonStubPromise(sinon) | |
let stubedFetch = sinon.stub(window, 'fetch') ) | |
window.fetch.returns(Promise.resolve(mockApiResponse())); | |
function mockApiResponse(body = {}) { | |
return new window.Response(JSON.stringify(body), { | |
status: 200, | |
headers: { 'Content-type': 'application/json' } | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment