Skip to content

Commit

Permalink
reject bad http status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
aremes committed Apr 8, 2016
1 parent 61e8fd5 commit 67653d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function adapter() {
var response = (handler[1] instanceof Function)
? handler[1](config)
: handler.slice(1);
resolve({
((response[0] === 1223) || (response[0] >= 200 && response[0] < 300 ) ? resolve : reject)
({
status: response[0],
data: response[1],
headers: response[2],
Expand Down
14 changes: 14 additions & 0 deletions test/mock_adapter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ describe('MockAdapter', function() {
});
});

it('rejects when the status is >= 300', function(done) {
mock.onGet('/moo').reply(500);

instance.get('/moo')
.then(
function(response) {
},
function(response) {
expect(response.status).to.equal(500);
done();
}
);
});

context('on the default instance', function() {
afterEach(function() {
axios.defaults.adapter = undefined;
Expand Down

0 comments on commit 67653d2

Please # to comment.