diff --git a/test/units.js b/test/units.js index 3759e2c..e93a71b 100644 --- a/test/units.js +++ b/test/units.js @@ -26,13 +26,20 @@ describe('Units:', () => { expect(actual).to.be.equal(expected); }); it( - 'should fail with wrong input', () => { + 'should pass even if options are not passed', () => { const res = { statusCode: 503, body: { key: 'value' } }; - expect(() => {generateErrorMessage(res)}).to.throw('options object missing'); + + const actual = generateErrorMessage(res); + const expected = + `Unexpected status code: 503, Body: { key: \'value\' }, Options: undefined`; + + expect(actual).to.be.equal(expected); }); + + it.only('should fail without response object', () => { expect(() => {generateErrorMessage()}).to.throw('response object missing'); }); }); diff --git a/units.js b/units.js index 39723b3..c9bc5d4 100644 --- a/units.js +++ b/units.js @@ -12,9 +12,6 @@ const generateErrorMessage = (res, options) => { if (!is(Object, res)) { throw new Error('response object missing') } - if (!is(Object, options)) { - throw new Error('options object missing') - } return `${`Unexpected status code: ${res.statusCode}, Body: ${util.inspect(res.body, { depth: 4 })}, Options: `}${util.inspect(options, { depth: 4 })}` } diff --git a/yarn.lock b/yarn.lock index 1f19307..aaac973 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1618,7 +1618,7 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" -"vm2@github:patriksimek/vm2#custom_files": +vm2@patriksimek/vm2#custom_files: version "3.5.0" resolved "https://codeload.github.com/patriksimek/vm2/tar.gz/7e82f90ac705fc44fad044147cb0df09b4c79a57"