@@ -267,6 +267,24 @@ describe('Error0', () => {
267267 expect ( AppError . serialize ( recreated , false ) ) . toEqual ( json )
268268 } )
269269
270+ it ( '.round() static and instance do serialize/from roundtrip' , ( ) => {
271+ const AppError = Error0 . use ( statusPlugin ) . use ( codePlugin )
272+ const error = new AppError ( 'test' , { status : 409 , code : 'NOT_FOUND' } )
273+ const roundedStatic = AppError . round ( error , false )
274+ const roundedInstance = error . round ( false )
275+
276+ expect ( roundedStatic ) . toBeInstanceOf ( AppError )
277+ expect ( roundedInstance ) . toBeInstanceOf ( AppError )
278+ expect ( roundedStatic . status ) . toBe ( 409 )
279+ expect ( roundedStatic . code ) . toBe ( 'NOT_FOUND' )
280+ expect ( roundedInstance . status ) . toBe ( 409 )
281+ expect ( roundedInstance . code ) . toBe ( 'NOT_FOUND' )
282+ expectTypeOf ( roundedStatic . status ) . toEqualTypeOf < number | undefined > ( )
283+ expectTypeOf ( roundedStatic . code ) . toEqualTypeOf < 'NOT_FOUND' | 'BAD_REQUEST' | 'UNAUTHORIZED' | undefined > ( )
284+ expectTypeOf ( roundedInstance . status ) . toEqualTypeOf < number | undefined > ( )
285+ expectTypeOf ( roundedInstance . code ) . toEqualTypeOf < 'NOT_FOUND' | 'BAD_REQUEST' | 'UNAUTHORIZED' | undefined > ( )
286+ } )
287+
270288 it ( '.serialize() floated props and not serialize causes' , ( ) => {
271289 const AppError = Error0 . use ( statusPlugin ) . use ( codePlugin )
272290 const error1 = new AppError ( 'test' , { status : 409 } )
@@ -277,7 +295,6 @@ describe('Error0', () => {
277295 expect ( 'cause' in json ) . toBe ( false )
278296 } )
279297
280-
281298 it ( 'by default causes not serialized' , ( ) => {
282299 const AppError = Error0 . use ( statusPlugin ) . use ( codePlugin )
283300 const error = new AppError ( 'test' , { status : 400 , code : 'NOT_FOUND' } )
@@ -554,7 +571,6 @@ describe('Error0', () => {
554571 expect ( error1 . code ) . toBe ( undefined )
555572 } )
556573
557-
558574 it ( 'messages can be combined on serialization' , ( ) => {
559575 const AppError = Error0 . use ( statusPlugin )
560576 . use ( codePlugin )
@@ -609,7 +625,6 @@ describe('Error0', () => {
609625 ` )
610626 } )
611627
612-
613628 it ( 'Error0 assignable to LikeError0' , ( ) => {
614629 type LikeError0 = {
615630 from : ( error : unknown ) => Error
0 commit comments