@@ -37,16 +37,7 @@ describe('cleanup unused imports schematic', () => {
3737 host = new TempScopedNodeJsSyncHost ( ) ;
3838 tree = new UnitTestTree ( new HostTree ( host ) ) ;
3939
40- writeFile (
41- '/tsconfig.json' ,
42- JSON . stringify ( {
43- compilerOptions : {
44- lib : [ 'es2015' ] ,
45- strictNullChecks : true ,
46- } ,
47- } ) ,
48- ) ;
49-
40+ writeFile ( '/tsconfig.json' , '{}' ) ;
5041 writeFile (
5142 '/angular.json' ,
5243 JSON . stringify ( {
@@ -253,4 +244,47 @@ describe('cleanup unused imports schematic', () => {
253244
254245 expect ( tree . readContent ( 'comp.ts' ) ) . toBe ( initialContent ) ;
255246 } ) ;
247+
248+ it ( 'should handle a file that is present in multiple projects' , async ( ) => {
249+ writeFile ( '/tsconfig-2.json' , '{}' ) ;
250+ writeFile (
251+ '/angular.json' ,
252+ JSON . stringify ( {
253+ version : 1 ,
254+ projects : {
255+ a : { root : '' , architect : { build : { options : { tsConfig : './tsconfig.json' } } } } ,
256+ b : { root : '' , architect : { build : { options : { tsConfig : './tsconfig-2.json' } } } } ,
257+ } ,
258+ } ) ,
259+ ) ;
260+
261+ writeFile (
262+ 'comp.ts' ,
263+ `
264+ import {Component} from '@angular/core';
265+ import {One, Two, Three} from './directives';
266+
267+ @Component({
268+ imports: [Three, One, Two],
269+ template: '<div one></div>',
270+ })
271+ export class Comp {}
272+ ` ,
273+ ) ;
274+
275+ await runMigration ( ) ;
276+
277+ expect ( stripWhitespace ( tree . readContent ( 'comp.ts' ) ) ) . toBe (
278+ stripWhitespace ( `
279+ import {Component} from '@angular/core';
280+ import {One} from './directives';
281+
282+ @Component({
283+ imports: [One],
284+ template: '<div one></div>',
285+ })
286+ export class Comp {}
287+ ` ) ,
288+ ) ;
289+ } ) ;
256290} ) ;
0 commit comments