Created
October 18, 2016 03:06
-
-
Save jsatk/c33e7e16435aa4ab647e1a3f53b4e08a 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 thirdPartyClient from 'some-third-party-client' | |
| import myApi from '../../src/my-api' | |
| describe('myApi', () => { | |
| describe('Error handling', () => { | |
| const myRejection = { | |
| errorCode: 404, | |
| errorMessage: 'You broke everything', | |
| errorUrl: 'http://coolapp.api.docs/error/404/' | |
| } | |
| beforeEach(() => { | |
| sinon.stub(thirdPartyClient.prototype, 'dingus') | |
| .returns(Promise.reject(myRejection) | |
| }) | |
| afterEach(() => thirdPartyClient.prototype.dingus.restore()) | |
| it('should be rejected with the correct error object', () => { | |
| const expected = myRejection | |
| return myApi.someMethod() | |
| .then(() => { | |
| const actual = thirdPartyClient.prototype.dingus | |
| return expect(actual).to.be.rejected | |
| .and.to.eventually.deep.equal(expected) | |
| }) | |
| }) | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment