Skip to content

Commit 46d930f

Browse files
refactor(): adjust coding style
1 parent 5f0829d commit 46d930f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

packages/common/test/utils/http-exception-body.util.spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@ import { createHttpExceptionBody } from '../../utils/http-exception-body.util';
33

44
describe('createHttpExceptionBody', () => {
55
it('should return pre-defined body if message is string', () => {
6-
expect(createHttpExceptionBody('message', 'error', 200)).to.eql({ message: 'message', error: 'error', statusCode: 200 });
6+
expect(createHttpExceptionBody('message', 'error', 200)).to.eql({
7+
message: 'message',
8+
error: 'error',
9+
statusCode: 200,
10+
});
711
});
812

913
it('should override pre-defined body if message is object', () => {
10-
expect(createHttpExceptionBody({ test: 'object' }, 'error', 200)).to.eql({ test: 'object' });
14+
expect(createHttpExceptionBody({ test: 'object' }, 'error', 200)).to.eql({
15+
test: 'object',
16+
});
1117
});
1218

1319
it('should not override pre-defined body if message is array', () => {
14-
expect(createHttpExceptionBody(['a', 'random', 'array'], 'error', 200)).to.eql({ message: ['a', 'random', 'array'], error: 'error', statusCode: 200 });
20+
expect(
21+
createHttpExceptionBody(['a', 'random', 'array'], 'error', 200),
22+
).to.eql({
23+
message: ['a', 'random', 'array'],
24+
error: 'error',
25+
statusCode: 200,
26+
});
1527
});
1628
});

packages/common/utils/http-exception-body.util.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ export const createHttpExceptionBody = (
88
if (!message) {
99
return { statusCode, error };
1010
}
11-
return isObject(message) && !Array.isArray(message) ? message : { statusCode, error, message };
11+
return isObject(message) && !Array.isArray(message)
12+
? message
13+
: { statusCode, error, message };
1214
};

0 commit comments

Comments
 (0)