Skip to content

Commit

Permalink
fix: Create error message without options
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-koval committed Jan 12, 2018
1 parent 9570014 commit 0db130a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
11 changes: 9 additions & 2 deletions test/units.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'); });
});
3 changes: 0 additions & 3 deletions units.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })}`
}

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ [email protected]:
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"

Expand Down

0 comments on commit 0db130a

Please sign in to comment.