1
1
import { describe , it } from 'mocha'
2
- import chai from 'chai'
2
+ import chai , { config } from 'chai'
3
3
import chaiAsPromised from 'chai-as-promised' ;
4
4
chai . use ( chaiAsPromised ) ;
5
5
import path from 'path'
@@ -25,6 +25,7 @@ import ImplementsOnePath from '../../Resources-ts/AutowireModulePath/src/Service
25
25
import ImplementsTwoPath from '../../Resources-ts/AutowireModulePath/src/Service/ImplementsTwo'
26
26
import PathExcludedService from '../../Resources-ts/AutowireModulePath/src/ToExclude/ExcludedService'
27
27
import PathInFolderExcludedService from '../../Resources-ts/AutowireModulePath/src/ToExclude/InFolderExclude/InFolderExcludedService'
28
+ import FooBarAutowireOverride from '../../Resources-ts/Autowire-Override/src/FooBarAutowireOverride'
28
29
import ServiceFile from '../../../lib/ServiceFile' ;
29
30
import RootDirectoryNotFound from '../../../lib/Exception/RootDirectoryNotFound' ;
30
31
@@ -36,6 +37,50 @@ describe('AutowireTS', () => {
36
37
const excludedServiceMessage = 'The service ExcludedService is not registered'
37
38
const inFolderExcludedMessage = 'The service InFolderExcludedService is not registered'
38
39
40
+ it ( "should not override single class with autowiring if not exists" , async ( ) => {
41
+ const configFile = path . join (
42
+ __dirname ,
43
+ '..' ,
44
+ '..' ,
45
+ resourcesTsFolder ,
46
+ 'Autowire-Override' ,
47
+ 'config' ,
48
+ 'services-not-exists.yaml'
49
+ )
50
+ const cb = new ContainerBuilder ( )
51
+ const loader = new YamlFileLoader ( cb )
52
+ await loader . load ( configFile )
53
+ await cb . compile ( )
54
+
55
+ // Act.
56
+ const actual = cb . get ( FooBarAutowireOverride )
57
+
58
+ // Assert.
59
+ assert . isUndefined ( actual . adapter )
60
+ } ) ;
61
+
62
+ it ( "should override single class with autowiring" , async ( ) => {
63
+ const configFile = path . join (
64
+ __dirname ,
65
+ '..' ,
66
+ '..' ,
67
+ resourcesTsFolder ,
68
+ 'Autowire-Override' ,
69
+ 'config' ,
70
+ 'services.yaml'
71
+ )
72
+ const cb = new ContainerBuilder ( )
73
+ const loader = new YamlFileLoader ( cb )
74
+ await loader . load ( configFile )
75
+ await cb . compile ( )
76
+
77
+ // Act.
78
+ const actual = cb . get ( FooBarAutowireOverride )
79
+
80
+ // Assert.
81
+ assert . equal ( actual . getString ( ) , "ci" )
82
+ } ) ;
83
+
39
84
it ( 'should get service file when was properly set' , ( ) => {
40
85
// Arrange.
41
86
const dir = path . join ( __dirname , '..' , '..' , resourcesTsFolder , 'Autowire' , 'src' )
0 commit comments