@@ -14,6 +14,7 @@ import { getFileContent } from '../utility/test';
1414import {
1515 addDeclarationToModule ,
1616 addExportToModule ,
17+ addProviderToModule ,
1718 addSymbolToNgModuleMetadata ,
1819} from './ast-utils' ;
1920
@@ -179,4 +180,29 @@ describe('ast utils', () => {
179180 expect ( output ) . toMatch ( / i m p o r t { F o o C o m p o n e n t } f r o m ' .\/ f o o .c o m p o n e n t ' ; / ) ;
180181 expect ( output ) . toMatch ( / e x p o r t s : \[ F o o C o m p o n e n t \] / ) ;
181182 } ) ;
183+
184+ it ( 'should add into providers metadata in new line ' , ( ) => {
185+ const moduleContent = `
186+ import { BrowserModule } from '@angular/platform-browser';
187+ import { NgModule } from '@angular/core';
188+
189+ @NgModule({
190+ imports: [BrowserModule],
191+ declarations: [],
192+ providers: [
193+ {
194+ provide: HTTP_INTERCEPTORS,
195+ useClass: AuthInterceptor,
196+ multi: true
197+ }
198+ ]
199+ })
200+ export class AppModule { }
201+ ` ;
202+ const source = getTsSource ( modulePath , moduleContent ) ;
203+ const changes = addProviderToModule ( source , modulePath , 'LogService' , './log.service' ) ;
204+ const output = applyChanges ( modulePath , moduleContent , changes ) ;
205+ expect ( output ) . toMatch ( / i m p o r t { L o g S e r v i c e } f r o m ' .\/ l o g .s e r v i c e ' ; / ) ;
206+ expect ( output ) . toMatch ( / \} , \r ? \n \s * L o g S e r v i c e \r ? \n \s * \] / ) ;
207+ } ) ;
182208} ) ;
0 commit comments