Skip to content

Commit 0f43cea

Browse files
authored
Merge pull request #8392 from IgniteUI/dpetev/migration-classes-package-name
chore(migrations): class rename - check properly handles both packages
2 parents b2ac474 + 8794955 commit 0f43cea

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
@@ -69,7 +69,7 @@ export function getImportModulePositions(sourceText: string, startsWith: string)
6969
/** Filters out statements to named imports (e.g. `import {x, y}`) from PACKAGE_IMPORT */
7070
const namedImportFilter = (statement: ts.Statement) => {
7171
if (statement.kind === ts.SyntaxKind.ImportDeclaration &&
72-
((statement as ts.ImportDeclaration).moduleSpecifier as ts.StringLiteral).text === IG_PACKAGE_NAME) {
72+
((statement as ts.ImportDeclaration).moduleSpecifier as ts.StringLiteral).text.endsWith(IG_PACKAGE_NAME)) {
7373

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

0 commit comments

Comments
 (0)