diff --git a/projects/cdk/schematics/ng-update/v4/steps/constants/identifiers-to-replace.ts b/projects/cdk/schematics/ng-update/v4/steps/constants/identifiers-to-replace.ts index f724da9f27bc..41fefcdef4ec 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/constants/identifiers-to-replace.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/constants/identifiers-to-replace.ts @@ -545,7 +545,10 @@ export const IDENTIFIERS_TO_REPLACE: ReplacementIdentifierMulti[] = [ {name: 'TuiScrollbarModule', moduleSpecifier: '@taiga-ui/core'}, {name: 'TuiScrollbarComponent', moduleSpecifier: '@taiga-ui/core'}, ], - to: {name: 'TuiScrollbar', moduleSpecifier: '@taiga-ui/core'}, + to: [ + {name: 'TuiScrollbar', moduleSpecifier: '@taiga-ui/core'}, + {name: 'TuiScrollable', moduleSpecifier: '@taiga-ui/core'}, + ], }, { from: [ diff --git a/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-scrollbar.spec.ts b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-scrollbar.spec.ts new file mode 100644 index 000000000000..1d5ebee41dea --- /dev/null +++ b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-scrollbar.spec.ts @@ -0,0 +1,128 @@ +import {join} from 'node:path'; + +import {HostTree} from '@angular-devkit/schematics'; +import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing'; +import type {TuiSchema} from '@taiga-ui/cdk/schematics/ng-add/schema'; +import { + createProject, + createSourceFile, + resetActiveProject, + saveActiveProject, + setActiveProject, +} from 'ng-morph'; + +import {createAngularJson} from '../../../utils/create-angular-json'; + +const collectionPath = join(__dirname, '../../../migration.json'); + +const COMPONENT_BEFORE = ` +import { TuiScrollbarModule } from "@taiga-ui/core"; + +@Component({ + standalone: true, + templateUrl: './test.template.html', + imports: [TuiScrollbarModule] +}) +export class Test { +}`; + +const COMPONENT_AFTER = `import { TuiScrollbar, TuiScrollable } from "@taiga-ui/core"; + +@Component({ + standalone: true, + templateUrl: './test.template.html', + imports: [TuiScrollbar, TuiScrollable] +}) +export class Test { +}`; + +const TEMPLATE_BEFORE = ` + + + + + + +
+ {{ item }} +
+
+
+`; + +const TEMPLATE_AFTER = ` + + + + + + +
+ {{ item }} +
+
+
+`; + +describe('ng-update', () => { + let host: UnitTestTree; + let runner: SchematicTestRunner; + + beforeEach(() => { + host = new UnitTestTree(new HostTree()); + runner = new SchematicTestRunner('schematics', collectionPath); + + setActiveProject(createProject(host)); + + createMainFiles(); + + saveActiveProject(); + }); + + it('should migrate scrollbar', async () => { + const tree = await runner.runSchematic( + 'updateToV4', + {'skip-logs': process.env['TUI_CI'] === 'true'} as Partial, + host, + ); + + expect(tree.readContent('test/app/test.component.ts')).toEqual(COMPONENT_AFTER); + expect(tree.readContent('test/app/test.template.html')).toEqual(TEMPLATE_AFTER); + }); + + afterEach(() => { + resetActiveProject(); + }); +}); + +function createMainFiles(): void { + createSourceFile('test/app/test.component.ts', COMPONENT_BEFORE); + + createSourceFile('test/app/test.template.html', TEMPLATE_BEFORE); + + createAngularJson(); + createSourceFile( + 'package.json', + '{"dependencies": {"@angular/core": "~13.0.0", "@taiga-ui/addon-commerce": "~3.42.0"}}', + ); +}