1- import { ActionParameterHandler } from " ../src/ActionParameterHandler" ;
2- import { ActionMetadata , ControllerMetadata , ExpressDriver , ParamMetadata } from " ../src" ;
3- import { ActionMetadataArgs } from " ../src/metadata/args/ActionMetadataArgs" ;
4- import { ControllerMetadataArgs } from " ../src/metadata/args/ControllerMetadataArgs" ;
5- import { ParamType } from " ../src/metadata/types/ParamType" ;
1+ import { ActionParameterHandler } from ' ../src/ActionParameterHandler' ;
2+ import { ActionMetadata , ControllerMetadata , ExpressDriver , ParamMetadata } from ' ../src' ;
3+ import { ActionMetadataArgs } from ' ../src/metadata/args/ActionMetadataArgs' ;
4+ import { ControllerMetadataArgs } from ' ../src/metadata/args/ControllerMetadataArgs' ;
5+ import { ParamType } from ' ../src/metadata/types/ParamType' ;
66
7- const expect = require ( " chakram" ) . expect ;
7+ const expect = require ( ' chakram' ) . expect ;
88
9- describe ( " ActionParameterHandler" , ( ) => {
9+ describe ( ' ActionParameterHandler' , ( ) => {
1010 const buildParamMetadata = (
11- name : string = "id" ,
12- type : ParamType = " param" ,
13- isRequired : boolean = false ,
11+ name : string = 'id' ,
12+ type : ParamType = ' param' ,
13+ isRequired : boolean = false
1414 ) : ParamMetadata => {
1515 const controllerMetadataArgs : ControllerMetadataArgs = {
16- target : function ( ) {
17- } ,
18- route : "" ,
19- type : "json" ,
16+ target : function ( ) { } ,
17+ route : '' ,
18+ type : 'json' ,
2019 options : { } ,
2120 } ;
2221 const controllerMetadata = new ControllerMetadata ( controllerMetadataArgs ) ;
2322 const args : ActionMetadataArgs = {
24- route : "" ,
25- method : " getProduct" ,
23+ route : '' ,
24+ method : ' getProduct' ,
2625 options : { } ,
27- target : function ( ) {
28- } ,
29- type : "get" ,
26+ target : function ( ) { } ,
27+ type : 'get' ,
3028 appendParams : undefined ,
3129 } ;
3230 const actionMetadata = new ActionMetadata ( controllerMetadata , args , { } ) ;
3331
3432 return {
3533 type,
3634 name,
37- targetName : " product" ,
35+ targetName : ' product' ,
3836 isTargetObject : true ,
3937 actionMetadata,
40- target : ( ) => {
41- } ,
42- method : "getProduct" ,
43- object : "getProduct" ,
38+ target : ( ) => { } ,
39+ method : 'getProduct' ,
40+ object : 'getProduct' ,
4441 extraOptions : undefined ,
4542 index : 0 ,
4643 parse : undefined ,
@@ -50,20 +47,19 @@ describe("ActionParameterHandler", () => {
5047 } ,
5148 classTransform : undefined ,
5249 validate : undefined ,
53- targetType : function ( ) {
54- } ,
50+ targetType : function ( ) { } ,
5551 } ;
5652 } ;
5753
58- it ( " handle - should process string parameters" , async ( ) => {
54+ it ( ' handle - should process string parameters' , async ( ) => {
5955 const driver = new ExpressDriver ( ) ;
6056 const actionParameterHandler = new ActionParameterHandler ( driver ) ;
61- const param = buildParamMetadata ( " uuid" ) ;
57+ const param = buildParamMetadata ( ' uuid' ) ;
6258
6359 const action = {
6460 request : {
6561 params : {
66- uuid : " 0b5ec98f-e26d-4414-b798-dcd35a5ef859" ,
62+ uuid : ' 0b5ec98f-e26d-4414-b798-dcd35a5ef859' ,
6763 } ,
6864 } ,
6965 response : { } ,
@@ -74,15 +70,15 @@ describe("ActionParameterHandler", () => {
7470 expect ( processedValue ) . to . be . eq ( action . request . params . uuid ) ;
7571 } ) ;
7672
77- it ( " handle - should process string parameters, returns empty if a given string is empty" , async ( ) => {
73+ it ( ' handle - should process string parameters, returns empty if a given string is empty' , async ( ) => {
7874 const driver = new ExpressDriver ( ) ;
7975 const actionParameterHandler = new ActionParameterHandler ( driver ) ;
80- const param = buildParamMetadata ( " uuid" ) ;
76+ const param = buildParamMetadata ( ' uuid' ) ;
8177
8278 const action = {
8379 request : {
8480 params : {
85- uuid : "" ,
81+ uuid : '' ,
8682 } ,
8783 } ,
8884 response : { } ,
@@ -93,10 +89,10 @@ describe("ActionParameterHandler", () => {
9389 expect ( processedValue ) . to . be . eq ( action . request . params . uuid ) ;
9490 } ) ;
9591
96- it ( " handle - should process number parameters" , async ( ) => {
92+ it ( ' handle - should process number parameters' , async ( ) => {
9793 const driver = new ExpressDriver ( ) ;
9894 const actionParameterHandler = new ActionParameterHandler ( driver ) ;
99- const param = buildParamMetadata ( "id" ) ;
95+ const param = buildParamMetadata ( 'id' ) ;
10096
10197 const action = {
10298 request : {
@@ -112,7 +108,7 @@ describe("ActionParameterHandler", () => {
112108 expect ( processedValue ) . to . be . eq ( action . request . params . id ) ;
113109 } ) ;
114110
115- it ( " handle - undefined on empty object provided" , async ( ) => {
111+ it ( ' handle - undefined on empty object provided' , async ( ) => {
116112 const driver = new ExpressDriver ( ) ;
117113 const actionParameterHandler = new ActionParameterHandler ( driver ) ;
118114 const param = buildParamMetadata ( ) ;
@@ -129,10 +125,10 @@ describe("ActionParameterHandler", () => {
129125 expect ( processedValue ) . to . be . eq ( undefined ) ;
130126 } ) ;
131127
132- it ( " handle - throws error if the parameter is required" , async ( ) => {
128+ it ( ' handle - throws error if the parameter is required' , async ( ) => {
133129 const driver = new ExpressDriver ( ) ;
134130 const actionParameterHandler = new ActionParameterHandler ( driver ) ;
135- const param = buildParamMetadata ( " uuid" , " param" , true ) ;
131+ const param = buildParamMetadata ( ' uuid' , ' param' , true ) ;
136132
137133 const action = {
138134 request : { } ,
@@ -146,13 +142,13 @@ describe("ActionParameterHandler", () => {
146142 error = e ;
147143 }
148144
149- expect ( error . toString ( ) ) . to . be . eq ( ' TypeError: Cannot read property \ 'uuid\ ' of undefined' ) ;
145+ expect ( error . toString ( ) ) . to . be . eq ( " TypeError: Cannot read property 'uuid' of undefined" ) ;
150146 } ) ;
151147
152- it ( " handle - throws error if the parameter is required, type file provided" , async ( ) => {
148+ it ( ' handle - throws error if the parameter is required, type file provided' , async ( ) => {
153149 const driver = new ExpressDriver ( ) ;
154150 const actionParameterHandler = new ActionParameterHandler ( driver ) ;
155- const param = buildParamMetadata ( " uuid" , " file" , true ) ;
151+ const param = buildParamMetadata ( ' uuid' , ' file' , true ) ;
156152
157153 const action = {
158154 request : { } ,
@@ -167,8 +163,7 @@ describe("ActionParameterHandler", () => {
167163 }
168164
169165 expect ( error . httpCode ) . to . be . eq ( 400 ) ;
170- expect ( error . name ) . to . be . eq ( " ParamRequiredError" ) ;
171- expect ( error . message ) . to . be . eq ( " Uploaded file \ "uuid\ " is required for request on undefined undefined" ) ;
166+ expect ( error . name ) . to . be . eq ( ' ParamRequiredError' ) ;
167+ expect ( error . message ) . to . be . eq ( ' Uploaded file "uuid" is required for request on undefined undefined' ) ;
172168 } ) ;
173-
174169} ) ;
0 commit comments