fix(ivy): injectable pipe schematic generating incorrect import statements (#30170)

Currently the injectable pipe schematic generates invalid imports like `import import { Pipe, PipeTransform, Injectable } from '@angular/core'; from '@angular/core';`. The issue wasn't caught by the unit tests, because the invalid import still contains the valid one.

Fixes #30159.

PR Close #30170
This commit is contained in:
crisbeto
2019-04-27 14:00:21 +02:00
committed by Andrew Kushnir
parent 537502d685
commit 6f433887e0
5 changed files with 19 additions and 27 deletions

View File

@ -85,7 +85,10 @@ describe('Google3 injectable pipe TSLint rule', () => {
`);
runTSLint();
expect(getFile('/index.ts')).toContain('import { Pipe, Injectable } from \'@angular/core\'');
const content = getFile('/index.ts');
expect(content).toContain('import { Pipe, Injectable } from \'@angular/core\'');
expect((content.match(/import/g) || []).length).toBe(1, 'Expected only one import statement');
});
});

View File

@ -70,8 +70,10 @@ describe('injectable pipe migration', () => {
`);
runMigration();
expect(tree.readContent('/index.ts'))
.toContain('import { Pipe, Injectable } from \'@angular/core\'');
const content = tree.readContent('/index.ts');
expect(content).toContain('import { Pipe, Injectable } from \'@angular/core\'');
expect((content.match(/import/g) || []).length).toBe(1, 'Expected only one import statement');
});
it('should not add an import for Injectable if it is imported already', () => {