@@ -24,7 +24,7 @@ test.group('Route | execute', () => {
2424 assert . plan ( 2 )
2525
2626 const stack : string [ ] = [ ]
27- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
27+ const app = new AppFactory ( ) . create ( BASE_URL )
2828 await app . init ( )
2929
3030 const context = new HttpContextFactory ( ) . create ( )
@@ -47,41 +47,40 @@ test.group('Route | execute', () => {
4747 } )
4848
4949 test ( 'execute route controller specified as a string' , async ( { assert } ) => {
50- assert . plan ( 3 )
51-
5250 const stack : string [ ] = [ ]
53- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
51+
52+ class HomeControllerClass {
53+ async handle ( ) {
54+ stack . push ( 'invoked handle' )
55+ }
56+ }
57+ const app = new AppFactory ( ) . create ( BASE_URL , ( filePath : string ) => {
58+ if ( filePath === '#controllers/home' ) {
59+ return {
60+ default : HomeControllerClass ,
61+ }
62+ }
63+ } )
5464 await app . init ( )
5565
5666 const resolver = app . container . createResolver ( )
57-
5867 const context = new HttpContextFactory ( ) . create ( )
5968
6069 const route = new Route ( app , [ ] , {
6170 pattern : '/' ,
6271 methods : [ 'GET' ] ,
63- handler : ( ) => { } ,
72+ handler : '#controllers/home' ,
6473 globalMatchers : { } ,
6574 } )
6675
6776 const routeJSON = route . toJSON ( )
68-
69- routeJSON . handler = {
70- reference : '#controllers/home' ,
71- async handle ( container , ctx ) {
72- assert . strictEqual ( container , resolver )
73- assert . strictEqual ( ctx , context )
74- stack . push ( 'controller' )
75- } ,
76- }
77-
7877 await routeJSON . execute ( routeJSON , resolver , context , ( ) => { } )
79- assert . deepEqual ( stack , [ 'controller ' ] )
78+ assert . deepEqual ( stack , [ 'invoked handle ' ] )
8079 } )
8180
8281 test ( 'execute route controller specified as lazy import' , async ( { assert } ) => {
8382 const stack : string [ ] = [ ]
84- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
83+ const app = new AppFactory ( ) . create ( BASE_URL )
8584 await app . init ( )
8685
8786 const resolver = app . container . createResolver ( )
@@ -128,7 +127,7 @@ test.group('Route | execute', () => {
128127
129128 test ( 'execute route controller specified as a class constructor' , async ( { assert } ) => {
130129 const stack : string [ ] = [ ]
131- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
130+ const app = new AppFactory ( ) . create ( BASE_URL )
132131 await app . init ( )
133132
134133 const resolver = app . container . createResolver ( )
@@ -171,7 +170,7 @@ test.group('Route | execute', () => {
171170 assert . plan ( 4 )
172171
173172 const stack : string [ ] = [ ]
174- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
173+ const app = new AppFactory ( ) . create ( BASE_URL )
175174 await app . init ( )
176175
177176 const context = new HttpContextFactory ( ) . create ( )
@@ -210,7 +209,7 @@ test.group('Route | execute', () => {
210209 assert . plan ( 3 )
211210
212211 const stack : string [ ] = [ ]
213- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
212+ const app = new AppFactory ( ) . create ( BASE_URL )
214213 await app . init ( )
215214
216215 const context = new HttpContextFactory ( ) . create ( )
@@ -246,7 +245,7 @@ test.group('Route | execute', () => {
246245 assert . plan ( 6 )
247246
248247 const stack : string [ ] = [ ]
249- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
248+ const app = new AppFactory ( ) . create ( BASE_URL )
250249 await app . init ( )
251250
252251 class BodyParserMiddleware {
@@ -313,7 +312,7 @@ test.group('Route | execute', () => {
313312 assert . plan ( 3 )
314313
315314 const stack : string [ ] = [ ]
316- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
315+ const app = new AppFactory ( ) . create ( BASE_URL )
317316 await app . init ( )
318317
319318 class BodyParserMiddleware {
@@ -375,7 +374,7 @@ test.group('Route | execute', () => {
375374
376375 test ( 'catch global middleware exceptions' , async ( { assert } ) => {
377376 const stack : string [ ] = [ ]
378- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
377+ const app = new AppFactory ( ) . create ( BASE_URL )
379378 await app . init ( )
380379
381380 class BodyParserMiddleware {
@@ -439,7 +438,7 @@ test.group('Route | execute', () => {
439438
440439 test ( 'catch route handler exceptions' , async ( { assert } ) => {
441440 const stack : string [ ] = [ ]
442- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
441+ const app = new AppFactory ( ) . create ( BASE_URL )
443442 await app . init ( )
444443
445444 class BodyParserMiddleware {
@@ -502,7 +501,7 @@ test.group('Route | execute', () => {
502501
503502 test ( 'pass arguments to the named middleware' , async ( { assert } ) => {
504503 const stack : any [ ] = [ ]
505- const app = new AppFactory ( ) . create ( BASE_URL , ( ) => { } )
504+ const app = new AppFactory ( ) . create ( BASE_URL )
506505 await app . init ( )
507506
508507 class AclMiddleware {
0 commit comments