Skip to content

Commit 2e72c63

Browse files
committed
Unit test for undefined or null options
1 parent db752fa commit 2e72c63

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

helpers/shouldRejectErrorResponse.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* @return boolean true if options.simple is set to use default value
66
*/
77
function shouldRejectErrorResponse (options) {
8+
if(!options) {
9+
return true;
10+
}
811
return (options.simple === undefined || options.simple === true);
912
}
1013

test/helpers/shouldRejectErrorResponse.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@ describe('shouldRejectErrorResponse', function () {
1313
it('should return false for options.simple false', function () {
1414
expect(shouldRejectErrorResponse({ simple: false })).to.equal(false);
1515
});
16+
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+
1625
});

0 commit comments

Comments
 (0)