Skip to content

Commit ea91554

Browse files
author
simonepri
committed
Add test
1 parent e1f10b8 commit ea91554

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,21 @@ test.serial('should mantain the error inheritance inalterated', t => {
189189
t.true(err instanceof Error);
190190
t.is(err.name, 'BadMethodError');
191191
});
192+
193+
test.serial('should create HttpError, and retain a prior cause', t => {
194+
const priorErr = new Error('foobar');
195+
196+
let err = new errors.HttpError(priorErr, 'new message');
197+
t.is(err.cause(), priorErr);
198+
t.is(err.name, 'HttpError');
199+
t.is(err.message, 'new message');
200+
t.is(err.body.message, 'new message');
201+
t.is(err.body.code, 'Error');
202+
203+
err = new errors.HttpError(priorErr, {message: 'bazinga!'});
204+
t.is(err.cause(), priorErr);
205+
t.is(err.name, 'HttpError');
206+
t.is(err.message, 'bazinga!');
207+
t.is(err.body.message, 'bazinga!');
208+
t.is(err.body.code, 'Error');
209+
});

0 commit comments

Comments
 (0)