11import express from "express"
2+ import { UserProvidedArgs , setDefaults } from "../../../../src/node/cli"
23import { errorHandler } from "../../../../src/node/routes/errors"
34
45describe ( "error page is rendered for text/html requests" , ( ) => {
@@ -9,7 +10,7 @@ describe("error page is rendered for text/html requests", () => {
910 statusCode : 404 ,
1011 message : ";>hello<script>alert(1)</script>" ,
1112 }
12- const req = createRequest ( )
13+ const req = await createRequest ( )
1314 const res = {
1415 status : jest . fn ( ) . mockReturnValue ( this ) ,
1516 send : jest . fn ( ) . mockReturnValue ( this ) ,
@@ -26,7 +27,7 @@ describe("error page is rendered for text/html requests", () => {
2627 statusCode : 404 ,
2728 message : "Not found" ,
2829 }
29- const req = createRequest ( { "app-name" : "MyCodeServer" } )
30+ const req = await createRequest ( { "app-name" : "MyCodeServer" } )
3031 const res = {
3132 status : jest . fn ( ) . mockReturnValue ( this ) ,
3233 send : jest . fn ( ) . mockReturnValue ( this ) ,
@@ -42,7 +43,7 @@ describe("error page is rendered for text/html requests", () => {
4243 statusCode : 500 ,
4344 message : "Internal error" ,
4445 }
45- const req = createRequest ( )
46+ const req = await createRequest ( )
4647 const res = {
4748 status : jest . fn ( ) . mockReturnValue ( this ) ,
4849 send : jest . fn ( ) . mockReturnValue ( this ) ,
@@ -54,7 +55,7 @@ describe("error page is rendered for text/html requests", () => {
5455 } )
5556} )
5657
57- function createRequest ( args ?: Record < string , string > ) : express . Request {
58+ async function createRequest ( args : UserProvidedArgs = { } ) : Promise < express . Request > {
5859 return {
5960 headers : {
6061 accept : [ "text/html" ] ,
@@ -63,6 +64,6 @@ function createRequest(args?: Record<string, string>): express.Request {
6364 query : {
6465 to : "test" ,
6566 } ,
66- args : args ,
67+ args : await setDefaults ( args ) ,
6768 } as unknown as express . Request
6869}
0 commit comments