@@ -132,7 +132,7 @@ describe("customRoutes()", () => {
132132 expect ( res . statusCode ) . toBe ( 200 ) ;
133133 } ) ;
134134
135- it ( "should set custom status code ( 418)" , async ( ) => {
135+ it ( "should set custom status code as number (statusCode= 418)" , async ( ) => {
136136 userConfig = [
137137 {
138138 route : "/foo" ,
@@ -144,7 +144,31 @@ describe("customRoutes()", () => {
144144 expect ( res . statusCode ) . toBe ( 418 ) ;
145145 } ) ;
146146
147- it ( "should set custom status code (404)" , async ( ) => {
147+ it ( "should set custom status code as string (statusCode='418')" , async ( ) => {
148+ userConfig = [
149+ {
150+ route : "/foo" ,
151+ statusCode : "418" ,
152+ } ,
153+ ] ;
154+ await customRoutes ( req , res , userConfig , false ) ;
155+
156+ expect ( res . statusCode ) . toBe ( 418 ) ;
157+ } ) ;
158+
159+ it ( "should not set custom status code if invalid code (statusCode='NaN')" , async ( ) => {
160+ userConfig = [
161+ {
162+ route : "/foo" ,
163+ statusCode : "NaN" ,
164+ } ,
165+ ] ;
166+ await customRoutes ( req , res , userConfig , false ) ;
167+
168+ expect ( res . statusCode ) . toBe ( 200 ) ;
169+ } ) ;
170+
171+ it ( "should set custom status code (statusCode=404)" , async ( ) => {
148172 userConfig = [
149173 {
150174 route : "/foo" ,
@@ -234,7 +258,7 @@ describe("customRoutes()", () => {
234258 expect ( req . url ) . toBe ( "/bar" ) ;
235259 } ) ;
236260
237- it ( "should serve with rewrite (statusCode = undefined)" , async ( ) => {
261+ it ( "should serve with rewrite (statusCode= undefined)" , async ( ) => {
238262 userConfig = [
239263 {
240264 route : "/foo" ,
0 commit comments