@@ -88,6 +88,8 @@ class NoAnnotations {
8888 constructor ( secretDependency ) { }
8989}
9090
91+ function factoryFn ( a ) { }
92+
9193export function main ( ) {
9294 var dynamicProviders = [
9395 provide ( 'provider0' , { useValue : 1 } ) ,
@@ -142,10 +144,20 @@ export function main() {
142144 expect ( car . engine ) . toBeAnInstanceOf ( TurboEngine ) ;
143145 } ) ;
144146
145- it ( 'should throw when no type and not @Inject' , ( ) => {
147+ it ( 'should throw when no type and not @Inject (class case) ' , ( ) => {
146148 expect ( ( ) => createInjector ( [ NoAnnotations ] ) )
147- . toThrowError ( 'Cannot resolve all parameters for NoAnnotations(?). ' +
148- 'Make sure they all have valid type or annotations.' ) ;
149+ . toThrowError (
150+ "Cannot resolve all parameters for 'NoAnnotations'(?). " +
151+ 'Make sure that all the parameters are decorated with Inject or have valid type annotations ' +
152+ "and that 'NoAnnotations' is decorated with Injectable." ) ;
153+ } ) ;
154+
155+ it ( 'should throw when no type and not @Inject (factory case)' , ( ) => {
156+ expect ( ( ) => createInjector ( [ provide ( "someToken" , { useFactory : factoryFn } ) ] ) )
157+ . toThrowError (
158+ "Cannot resolve all parameters for 'factoryFn'(?). " +
159+ 'Make sure that all the parameters are decorated with Inject or have valid type annotations ' +
160+ "and that 'factoryFn' is decorated with Injectable." ) ;
149161 } ) ;
150162
151163 it ( 'should cache instances' , ( ) => {
0 commit comments