|
| 1 | +import * as path from 'path'; |
| 2 | + |
| 3 | +// tslint:disable:no-implicit-dependencies |
| 4 | +import { virtualFs } from '@angular-devkit/core'; |
| 5 | +import { EmptyTree } from '@angular-devkit/schematics'; |
| 6 | +// tslint:disable-next-line:no-submodule-imports |
| 7 | +import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; |
| 8 | + |
| 9 | +describe('Update 10.1.0', () => { |
| 10 | + let appTree: UnitTestTree; |
| 11 | + const schematicRunner = new SchematicTestRunner('ig-migrate', path.join(__dirname, '../migration-collection.json')); |
| 12 | + const configJson = { |
| 13 | + defaultProject: 'testProj', |
| 14 | + projects: { |
| 15 | + testProj: { |
| 16 | + sourceRoot: '/testSrc' |
| 17 | + } |
| 18 | + }, |
| 19 | + schematics: { |
| 20 | + '@schematics/angular:component': { |
| 21 | + prefix: 'appPrefix' |
| 22 | + } |
| 23 | + } |
| 24 | + }; |
| 25 | + |
| 26 | + beforeEach(() => { |
| 27 | + appTree = new UnitTestTree(new EmptyTree()); |
| 28 | + appTree.create('/angular.json', JSON.stringify(configJson)); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should upgrade the igx-action-icon to igx-navbar-action', async () => { |
| 32 | + appTree.create( |
| 33 | + '/testSrc/appPrefix/component/custom.component.html', |
| 34 | + `<igx-navbar title="Test title"> |
| 35 | + <igx-action-icon> |
| 36 | + <igx-icon>arrow_back</igx-icon> |
| 37 | + </igx-action-icon> |
| 38 | + </igx-navbar>`); |
| 39 | + const tree = await schematicRunner.runSchematicAsync('migration-16', {}, appTree) |
| 40 | + .toPromise(); |
| 41 | + |
| 42 | + expect(tree.readContent('/testSrc/appPrefix/component/custom.component.html')) |
| 43 | + .toEqual( |
| 44 | + `<igx-navbar title="Test title"> |
| 45 | + <igx-navbar-action> |
| 46 | + <igx-icon>arrow_back</igx-icon> |
| 47 | + </igx-navbar-action> |
| 48 | + </igx-navbar>`); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should update IgxActionIconDirective to IgxNavbarActionDirective', async () => { |
| 52 | + appTree.create('/testSrc/appPrefix/component/custom.component.ts', |
| 53 | + `import { IgxActionIconDirective } from 'igniteui-angular'; |
| 54 | + export class TestNavbar { |
| 55 | + @ViewChild(IgxActionIconDirective, { read: IgxActionIconDirective }) |
| 56 | + private actionIcon: IgxActionIconDirective; }`); |
| 57 | + |
| 58 | + const tree = await schematicRunner.runSchematicAsync('migration-16', {}, appTree).toPromise(); |
| 59 | + |
| 60 | + expect(tree.readContent('/testSrc/appPrefix/component/custom.component.ts')) |
| 61 | + .toEqual( |
| 62 | + `import { IgxNavbarActionDirective } from 'igniteui-angular'; |
| 63 | + export class TestNavbar { |
| 64 | + @ViewChild(IgxNavbarActionDirective, { read: IgxNavbarActionDirective }) |
| 65 | + private actionIcon: IgxNavbarActionDirective; }`); |
| 66 | + }); |
| 67 | + |
| 68 | +}); |
0 commit comments