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:
@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -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', () => {
|
||||
|
Reference in New Issue
Block a user