Skip to content

Commit 177c998

Browse files
committed
fix: Test-coverage return-branch unwrap error
1 parent 7b0e4b6 commit 177c998

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/error/unwrapErrorType.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ class NonRecoverableError extends Error {
1919
}
2020

2121
describe('unwrapErrorType', () => {
22+
it('returns null for nullish and non-object errors', () => {
23+
expect(unwrapErrorType(CustomError, null)).toBeNull();
24+
expect(unwrapErrorType(CustomError, undefined)).toBeNull();
25+
expect(unwrapErrorType(CustomError, 'boom')).toBeNull();
26+
expect(unwrapErrorType(CustomError, 123)).toBeNull();
27+
expect(unwrapErrorType(CustomError, true)).toBeNull();
28+
expect(unwrapErrorType(CustomError, Symbol('boom'))).toBeNull();
29+
expect(unwrapErrorType(CustomError, () => new Error('boom'))).toBeNull();
30+
});
31+
2232
it('non-error correctly returns false', () => {
2333
const nonErr = { foo: 'bar' };
2434

0 commit comments

Comments
 (0)