File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 55
66import { Binding , Context } from '@loopback/context' ;
77import { expect } from '@loopback/testlab' ;
8+ import { types } from 'util' ;
89import { CoreTags , service } from '../..' ;
910import { asService } from '../../service' ;
1011
@@ -73,6 +74,20 @@ describe('@service', () => {
7374 expect ( controller . myService ) . to . be . undefined ( ) ;
7475 } ) ;
7576
77+ it ( 'allows asProxyWithInterceptors flag' , async ( ) => {
78+ class MyController {
79+ constructor (
80+ @service ( MyService , { asProxyWithInterceptors : true } )
81+ public myService ?: MyService ,
82+ ) { }
83+ }
84+
85+ ctx . bind ( 'controllers.MyController' ) . toClass ( MyController ) ;
86+
87+ const controller = await ctx . get < MyController > ( 'controllers.MyController' ) ;
88+ expect ( types . isProxy ( controller . myService ) ) . to . be . true ( ) ;
89+ } ) ;
90+
7691 it ( 'allows serviceInterface as a string' , async ( ) => {
7792 class MyController {
7893 constructor ( @service ( 'MyService' ) public myService : MyService ) { }
Original file line number Diff line number Diff line change @@ -109,7 +109,11 @@ export function service(
109109 ) ;
110110 }
111111 const view = new ContextView ( ctx , filterByServiceInterface ( serviceType ) ) ;
112- const result = view . resolve ( session ) ;
112+ const result = view . resolve ( {
113+ optional : metadata ?. optional ,
114+ asProxyWithInterceptors : metadata ?. asProxyWithInterceptors ,
115+ session,
116+ } ) ;
113117
114118 const serviceTypeName =
115119 typeof serviceType === 'string'
You can’t perform that action at this time.
0 commit comments