Skip to content

Instantly share code, notes, and snippets.

@deepak
Created August 31, 2016 09:11
Show Gist options
  • Save deepak/12a8c0ea9734d541408163984ab91343 to your computer and use it in GitHub Desktop.
Save deepak/12a8c0ea9734d541408163984ab91343 to your computer and use it in GitHub Desktop.
mocha mock does not work
it('needs auth to be passed in', (done) => {
const usedMock = nock('http://example.com/v1', {
reqheaders: {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": `Basic ${btoa(auth)}`
}
}).post('/user').reply(200, jsonResponse);
const storedAuthMock = nock('http://example.com/v1', {
reqheaders: {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": `Basic ${btoa("stored-user:password")}`
}
}).post('/merchant').reply(200, jsonResponse);
const promise = apiFetch.postQuick({
endpoint: "merchant",
auth
});
promise
.then((data) => {
expect(data).not.to.deep.equal({ "msg": "Hello world!" });
})
.catch((err) => done(err));
expect(storedAuthMock.isDone).to.be.false;
usedMock.done();
done();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment