|
| 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 update DropPosition.None', done => { |
| 32 | + const origFileContent = |
| 33 | + `import { Component, Injectable, ViewChild } from "@angular/core";` + |
| 34 | + `import { IgxGridComponent, DropPosition } from "igniteui-angular";` + |
| 35 | + `import { IgxColumnComponent } from "igniteui-angular";\r\n` + |
| 36 | + `@Component({` + |
| 37 | + ` providers: [RemoteService]` + |
| 38 | + `})` + |
| 39 | + `export class GridSampleComponent {` + |
| 40 | + ` @ViewChild("grid1", { read: IgxGridComponent }) public grid1: IgxGridComponent;` + |
| 41 | + ` public move() {` + |
| 42 | + ` const column: IgxColumnComponent = this.grid1.columns[0];` + |
| 43 | + ` const column2: IgxColumnComponent = this.grid1.columns[1];` + |
| 44 | + ` this.grid1.moveColumn(col1, col2, DropPosition.None);` + |
| 45 | + ` }` + |
| 46 | + `}`; |
| 47 | + const expectedFileContent = |
| 48 | + `import { Component, Injectable, ViewChild } from "@angular/core";` + |
| 49 | + `import { IgxGridComponent, DropPosition } from "igniteui-angular";` + |
| 50 | + `import { IgxColumnComponent } from "igniteui-angular";\r\n` + |
| 51 | + `@Component({` + |
| 52 | + ` providers: [RemoteService]` + |
| 53 | + `})` + |
| 54 | + `export class GridSampleComponent {` + |
| 55 | + ` @ViewChild("grid1", { read: IgxGridComponent }) public grid1: IgxGridComponent;` + |
| 56 | + ` public move() {` + |
| 57 | + ` const column: IgxColumnComponent = this.grid1.columns[0];` + |
| 58 | + ` const column2: IgxColumnComponent = this.grid1.columns[1];` + |
| 59 | + ` this.grid1.moveColumn(col1, col2, DropPosition.AfterDropTarget);` + |
| 60 | + ` }` + |
| 61 | + `}`; |
| 62 | + appTree.create( |
| 63 | + '/testSrc/appPrefix/component/drop.component.ts', |
| 64 | + origFileContent); |
| 65 | + |
| 66 | + const tree = schematicRunner.runSchematic('migration-16', {}, appTree); |
| 67 | + expect(tree.readContent('/testSrc/appPrefix/component/drop.component.ts')) |
| 68 | + .toEqual(expectedFileContent); |
| 69 | + done(); |
| 70 | + }); |
| 71 | +}); |
0 commit comments