Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
status is now statusCode (#41)
Browse files Browse the repository at this point in the history
Add test

Wording

Better wording
  • Loading branch information
dragonfire535 authored and devsnek committed Jun 6, 2018
1 parent 32c5da6 commit b9d53f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class Snekfetch extends transport.Parent {
end(cb) {
return this.then(
(res) => (cb ? cb(null, res) : res),
(err) => (cb ? cb(err, err.status ? err : null) : Promise.reject(err)),
(err) => (cb ? cb(err, err.statusCode ? err : null) : Promise.reject(err)),
);
}

Expand Down
7 changes: 7 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,10 @@ test('redirects', () =>
expect(res.body).not.toBeUndefined();
expect(res.body.url).toBe(`${TestRoot}/get`);
}));

test('res should be defined when rejecting', () =>
Snekfetch.get(`${TestRoot}/404`)
.end((err, res) => {
expect(err.statusCode).not.toBeUndefined();
expect(res).not.toBe(null);
}));

0 comments on commit b9d53f5

Please sign in to comment.