@@ -46,10 +46,19 @@ describe("action options", () => {
46
46
@JsonController ( "" , { transformResponse : false } )
47
47
class NoTransformResponseController {
48
48
@Post ( "/default" )
49
- default ( @Body ( ) user : UserModel ) { return handler ( user ) ; }
49
+ default ( @Body ( ) user : UserModel ) {
50
+ return handler ( user ) ;
51
+ }
50
52
51
- @Post ( "/override" , { transformRequest : false , transformResponse : true } )
52
- transform ( @Body ( ) user : UserModel ) { return handler ( user ) ; }
53
+ @Post ( "/transformRequestOnly" , { transformRequest : true , transformResponse : false } )
54
+ transformRequestOnly ( @Body ( ) user : UserModel ) {
55
+ return handler ( user ) ;
56
+ }
57
+
58
+ @Post ( "/transformResponseOnly" , { transformRequest : false , transformResponse : true } )
59
+ transformResponseOnly ( @Body ( ) user : UserModel ) {
60
+ return handler ( user ) ;
61
+ }
53
62
}
54
63
} ) ;
55
64
@@ -64,12 +73,21 @@ describe("action options", () => {
64
73
expect ( initializedUser ) . to . be . instanceOf ( User ) ;
65
74
expect ( initializedUser . lastName ) . to . be . undefined ;
66
75
expect ( response ) . to . have . status ( 200 ) ;
67
- expect ( response . body . lastName ) . to . exist ;
76
+ expect ( response . body . lastName ) . to . equal ( "default" ) ;
77
+ } ) ;
78
+ } ) ;
79
+
80
+ it ( "should override controller options with action transformRequest option" , ( ) => {
81
+ assertRequest ( [ 3001 , 3002 ] , "post" , "transformRequestOnly" , { firstName : "Umed" , lastName : "Khudoiberdiev" } , response => {
82
+ expect ( initializedUser ) . to . be . instanceOf ( User ) ;
83
+ expect ( initializedUser . lastName ) . to . be . undefined ;
84
+ expect ( response ) . to . have . status ( 200 ) ;
85
+ expect ( response . body . lastName ) . to . equal ( "default" ) ;
68
86
} ) ;
69
87
} ) ;
70
88
71
- it ( "should override controller options when action transform options are set " , ( ) => {
72
- assertRequest ( [ 3001 , 3002 ] , "post" , "override " , { firstName : "Umed" , lastName : "Khudoiberdiev" } , response => {
89
+ it ( "should override controller options with action transformResponse option " , ( ) => {
90
+ assertRequest ( [ 3001 , 3002 ] , "post" , "transformResponseOnly " , { firstName : "Umed" , lastName : "Khudoiberdiev" } , response => {
73
91
expect ( initializedUser ) . not . to . be . instanceOf ( User ) ;
74
92
expect ( initializedUser . lastName ) . to . exist ;
75
93
expect ( response ) . to . have . status ( 200 ) ;
0 commit comments