Skip to content

Commit fea5f38

Browse files
authored
Merge pull request #8391 from IgniteUI/dpetev/migration-classes-package-name-10.1
chore(migrations): class rename - check properly handles both packages
2 parents 9d67850 + f5fe76d commit fea5f38

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

projects/igniteui-angular/migrations/common/UpdateChanges.spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ describe('UpdateChanges', () => {
390390
});
391391
spyOn<any>(fs, 'readFileSync').and.callFake(() => JSON.stringify(classJson));
392392

393-
const fileContent =
393+
let fileContent =
394394
`import { Size, Type as someThg } from "igniteui-angular";
395395
import { IgxService, IgxDiffService as eDiffService, Calendar as Calendar } from 'igniteui-angular';
396396
import { Type } from "@angular/core";
@@ -411,7 +411,7 @@ export class Test {
411411
expect(update.getClassChanges()).toEqual(classJson);
412412

413413
update.applyChanges();
414-
expect(appTree.readContent('test.component.ts')).toEqual(
414+
let expectedFileContent =
415415
`import { IgxSize, IgxType as someThg } from "igniteui-angular";
416416
import { IgxService1, IgxNewDiffService as eDiffService, CalendarActual as Calendar } from 'igniteui-angular';
417417
import { Type } from "@angular/core";
@@ -423,8 +423,15 @@ export class Test {
423423
cal: Calendar;
424424
425425
constructor (public router: Router, private _iconService: IgxService1) {}
426-
}`
427-
);
426+
}`;
427+
expect(appTree.readContent('test.component.ts')).toEqual(expectedFileContent);
428+
429+
// with ig feed package:
430+
fileContent = fileContent.replace(/igniteui-angular/g, '@infragistics/igniteui-angular');
431+
expectedFileContent = expectedFileContent.replace(/igniteui-angular/g, '@infragistics/igniteui-angular');
432+
appTree.overwrite('test.component.ts', fileContent);
433+
update.applyChanges();
434+
expect(appTree.readContent('test.component.ts')).toEqual(expectedFileContent);
428435
});
429436

430437
it('should move property value between element tags', done => {

projects/igniteui-angular/migrations/common/tsUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function getImportModulePositions(sourceText: string, startsWith: string)
6464
/** Filters out statements to named imports (e.g. `import {x, y}`) from PACKAGE_IMPORT */
6565
const namedImportFilter = (statement: ts.Statement) => {
6666
if (statement.kind === ts.SyntaxKind.ImportDeclaration &&
67-
((statement as ts.ImportDeclaration).moduleSpecifier as ts.StringLiteral).text === PACKAGE_IMPORT) {
67+
((statement as ts.ImportDeclaration).moduleSpecifier as ts.StringLiteral).text.endsWith(PACKAGE_IMPORT)) {
6868

6969
const clause = (statement as ts.ImportDeclaration).importClause;
7070
return clause && clause.namedBindings && clause.namedBindings.kind === ts.SyntaxKind.NamedImports;

0 commit comments

Comments
 (0)