Created
August 31, 2016 09:11
-
-
Save deepak/12a8c0ea9734d541408163984ab91343 to your computer and use it in GitHub Desktop.
mocha mock does not work
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
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