@@ -45,26 +45,28 @@ describe('HttpException', () => {
4545 } ) ;
4646 } ) ;
4747
48- it ( 'Should inherit from error' , ( ) => {
48+ it ( 'should inherit from error' , ( ) => {
4949 const error = new HttpException ( '' , 400 ) ;
5050 expect ( error instanceof Error ) . to . be . true ;
5151 } ) ;
5252
53- it ( 'Should be serializable' , ( ) => {
53+ it ( 'should be serializable' , ( ) => {
5454 const message = 'Some Error' ;
5555 const error = new HttpException ( message , 400 ) ;
5656 expect ( `${ error } ` ) . to . be . eql ( `Error: ${ message } ` ) ;
5757 } ) ;
5858
59- it ( 'Should serialize objects' , ( ) => {
60- const obj = { foo : 'bar' } ;
61- const error = new HttpException ( obj , 400 ) ;
62- expect ( `${ error } ` ) . to . be . eql ( `Error: ${ JSON . stringify ( obj ) } ` ) ;
63- expect ( `${ error } ` . includes ( '[object Object]' ) ) . to . not . be . true ;
64- } ) ;
59+ describe ( 'when "message" is an object' , ( ) => {
60+ it ( 'should serialize an object' , ( ) => {
61+ const obj = { foo : 'bar' } ;
62+ const error = new HttpException ( obj , 400 ) ;
63+ expect ( `${ error } ` ) . to . be . eql ( `Error: ${ JSON . stringify ( obj ) } ` ) ;
64+ expect ( `${ error } ` . includes ( '[object Object]' ) ) . to . not . be . true ;
65+ } ) ;
6566
66- it ( 'Should serialize sub errors' , ( ) => {
67- const error = new NotFoundException ( ) ;
68- expect ( `${ error } ` . includes ( 'Not Found' ) ) . to . be . true ;
67+ it ( 'should serialize sub errors' , ( ) => {
68+ const error = new NotFoundException ( ) ;
69+ expect ( `${ error } ` . includes ( 'Not Found' ) ) . to . be . true ;
70+ } ) ;
6971 } ) ;
7072} ) ;
0 commit comments