@@ -14,6 +14,7 @@ import { getFileContent } from '../utility/test';
14
14
import {
15
15
addDeclarationToModule ,
16
16
addExportToModule ,
17
+ addProviderToModule ,
17
18
addSymbolToNgModuleMetadata ,
18
19
} from './ast-utils' ;
19
20
@@ -179,4 +180,29 @@ describe('ast utils', () => {
179
180
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 ' ; / ) ;
180
181
expect ( output ) . toMatch ( / e x p o r t s : \[ F o o C o m p o n e n t \] / ) ;
181
182
} ) ;
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
+ } ) ;
182
208
} ) ;
0 commit comments