Skip to content

Commit dd43fac

Browse files
committed
Code review comments
1 parent c828901 commit dd43fac

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
/**
22
* Checks if the options.simple is set to use default.
3+
* By default, http response codes other than 2xx will cause the promise to be rejected. This can be overwritten by setting `options.simple = false`.
34
*
45
* @param options a request.options object
5-
* @return boolean true if options.simple is set to use default value
6+
* @return boolean true if non successful response should be rejected, otherwise false
67
*/
78
function shouldRejectErrorResponse (options) {
89
if (!options) {
910
return true;
1011
}
11-
return (options.simple === undefined || options.simple === true);
12+
return options.simple === undefined || options.simple === true;
1213
}
1314

1415
module.exports = shouldRejectErrorResponse;

test/helpers/shouldRejectErrorResponse.test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ const shouldRejectErrorResponse = require('../../helpers/shouldRejectErrorRespon
44
const expect = require('chai').expect;
55

66
describe('shouldRejectErrorResponse', function () {
7+
8+
it('should return true for options is null', function () {
9+
expect(shouldRejectErrorResponse(null)).to.equal(true);
10+
});
11+
12+
it('should return true for options is undefined', function () {
13+
expect(shouldRejectErrorResponse(undefined)).to.equal(true);
14+
});
15+
716
[{ simple: true }, {}].forEach(options => {
817
it(`should return true for ${options.simple} simple`, function () {
918
expect(shouldRejectErrorResponse({ options: options })).to.equal(true);
@@ -14,12 +23,4 @@ describe('shouldRejectErrorResponse', function () {
1423
expect(shouldRejectErrorResponse({ simple: false })).to.equal(false);
1524
});
1625

17-
it('should return true for options is null', function () {
18-
expect(shouldRejectErrorResponse(null)).to.equal(true);
19-
});
20-
21-
it('should return true for options is undefined', function () {
22-
expect(shouldRejectErrorResponse(undefined)).to.equal(true);
23-
});
24-
2526
});

0 commit comments

Comments
 (0)