@@ -822,6 +822,58 @@ describe('AutowireTS - Bind', () => {
822822 assert . strictEqual ( container . binds . get ( 'someParam' ) , 'someValue' )
823823 } )
824824} )
825+
826+ describe ( 'AutowireTS - dumpFile' , ( ) => {
827+ const resourcesTsFolder = 'Resources-ts'
828+ const autowireFolder = 'Autowire'
829+ const dir = path . join ( __dirname , '..' , '..' , resourcesTsFolder , autowireFolder , 'src' )
830+ const dumpFilePath = '/tmp/services-dump-file-test.yaml'
831+
832+ it ( 'should generate a dump file when dumpFile is set in YAML _defaults' , async ( ) => {
833+ // Arrange.
834+ const configFile = path . join (
835+ __dirname , '..' , '..' , resourcesTsFolder , autowireFolder , 'config' , 'services-dump-file.yaml'
836+ )
837+ const container = new ContainerBuilder ( false , dir )
838+ const loader = new YamlFileLoader ( container )
839+
840+ // Act.
841+ await loader . load ( configFile )
842+ await container . compile ( )
843+
844+ // Assert: load the dumped file in a new container and verify services work
845+ const containerDump = new ContainerBuilder ( false , dir )
846+ const dumpLoader = new YamlFileLoader ( containerDump )
847+ await dumpLoader . load ( dumpFilePath )
848+
849+ assert . instanceOf ( containerDump . get ( FooBar ) , FooBar )
850+ assert . instanceOf ( containerDump . get ( Foo ) , Foo )
851+ assert . instanceOf ( containerDump . get ( Bar ) , Bar )
852+ } )
853+
854+ it ( 'should generate a dump file when dumpFile is a relative path in YAML _defaults' , async ( ) => {
855+ // Arrange.
856+ const relativeDumpFilePath = '/tmp/services-dump-file-relative-test.yaml'
857+ const configFile = path . join (
858+ __dirname , '..' , '..' , resourcesTsFolder , autowireFolder , 'config' , 'services-dump-file-relative.yaml'
859+ )
860+ const container = new ContainerBuilder ( false , dir )
861+ const loader = new YamlFileLoader ( container )
862+
863+ // Act.
864+ await loader . load ( configFile )
865+ await container . compile ( )
866+
867+ // Assert: load the dumped file in a new container and verify services work
868+ const containerDump = new ContainerBuilder ( false , dir )
869+ const dumpLoader = new YamlFileLoader ( containerDump )
870+ await dumpLoader . load ( relativeDumpFilePath )
871+
872+ assert . instanceOf ( containerDump . get ( FooBar ) , FooBar )
873+ assert . instanceOf ( containerDump . get ( Foo ) , Foo )
874+ assert . instanceOf ( containerDump . get ( Bar ) , Bar )
875+ } )
876+ } )
825877import KeyedCheckoutService from '../../Resources-ts/Autowire-Keyed/src/Service/KeyedCheckoutService'
826878import KeyedPaymentRouterService from '../../Resources-ts/Autowire-Keyed/src/Service/KeyedPaymentRouterService'
827879import StripePaymentService from '../../Resources-ts/Autowire-Keyed/src/Service/StripePaymentService'
0 commit comments