This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,8 +102,12 @@ function readAnnotations(fn) {
102102 if ( fn . annotations && fn . annotations . length ) {
103103 for ( var annotation of fn . annotations ) {
104104 if ( annotation instanceof Inject ) {
105- collectedAnnotations . params = annotation . tokens . map ( ( token ) => {
106- return { token : token , isPromise : annotation . isPromise , isLazy : annotation . isLazy } ;
105+ annotation . tokens . forEach ( ( token ) => {
106+ collectedAnnotations . params . push ( {
107+ token : token ,
108+ isPromise : annotation . isPromise ,
109+ isLazy : annotation . isLazy
110+ } ) ;
107111 } ) ;
108112 }
109113
Original file line number Diff line number Diff line change @@ -158,4 +158,29 @@ describe('readAnnotations', function() {
158158 expect ( annotations . params [ 1 ] . isPromise ) . toBe ( false ) ;
159159 expect ( annotations . params [ 1 ] . isLazy ) . toBe ( false ) ;
160160 } ) ;
161+
162+ it ( 'should read stacked @Inject{Lazy, Promise} annotations' , function ( ) {
163+ class One { }
164+ class Two { }
165+ class Three { }
166+
167+ @Inject ( One )
168+ @InjectLazy ( Two )
169+ @InjectPromise ( Three )
170+ class Foo { }
171+
172+ var annotations = readAnnotations ( Foo ) ;
173+
174+ expect ( annotations . params [ 0 ] . token ) . toBe ( One ) ;
175+ expect ( annotations . params [ 0 ] . isPromise ) . toBe ( false ) ;
176+ expect ( annotations . params [ 0 ] . isLazy ) . toBe ( false ) ;
177+
178+ expect ( annotations . params [ 1 ] . token ) . toBe ( Two ) ;
179+ expect ( annotations . params [ 1 ] . isPromise ) . toBe ( false ) ;
180+ expect ( annotations . params [ 1 ] . isLazy ) . toBe ( true ) ;
181+
182+ expect ( annotations . params [ 2 ] . token ) . toBe ( Three ) ;
183+ expect ( annotations . params [ 2 ] . isPromise ) . toBe ( true ) ;
184+ expect ( annotations . params [ 2 ] . isLazy ) . toBe ( false ) ;
185+ } ) ;
161186} ) ;
You can’t perform that action at this time.
0 commit comments