Skip to content

Commit

Permalink
test(migrations): add members tests related to icon changes
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonoff committed Jan 15, 2021
1 parent 80c7ecf commit 9b3ddde
Showing 1 changed file with 80 additions and 8 deletions.
88 changes: 80 additions & 8 deletions projects/igniteui-angular/migrations/update-11_1_0/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as path from 'path';

import { EmptyTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import {
SchematicTestRunner,
UnitTestTree,
} from '@angular-devkit/schematics/testing';

describe('Update to 11.1.0', () => {
let appTree: UnitTestTree;
Expand Down Expand Up @@ -34,12 +37,13 @@ describe('Update to 11.1.0', () => {
'<igx-icon fontSet="material">settings</igx-icon>'
);

const tree = await runner.runSchematicAsync('migration-19', {}, appTree)
const tree = await runner
.runSchematicAsync('migration-19', {}, appTree)
.toPromise();

expect(tree.readContent('/testSrc/appPrefix/component/icon.component.html'))
.toEqual('<igx-icon family="material">settings</igx-icon>');

expect(
tree.readContent('/testSrc/appPrefix/component/icon.component.html')
).toEqual('<igx-icon family="material">settings</igx-icon>');
});

it('should update isActive to active', async () => {
Expand All @@ -48,11 +52,79 @@ describe('Update to 11.1.0', () => {
'<igx-icon [isActive]="false">settings</igx-icon>'
);

const tree = await runner.runSchematicAsync('migration-19', {}, appTree)
const tree = await runner
.runSchematicAsync('migration-19', {}, appTree)
.toPromise();

expect(tree.readContent('/testSrc/appPrefix/component/icon.component.html'))
.toEqual('<igx-icon [active]="false">settings</igx-icon>');
expect(
tree.readContent('/testSrc/appPrefix/component/icon.component.html')
).toEqual('<igx-icon [active]="false">settings</igx-icon>');
});

it('should migrate updated getter names', async () => {
appTree.create(
'/testSrc/appPrefix/component/icon-test.component.ts',
`import { Component, ViewChild } from '@angular/core';
import { IgxIconModule, IgxIconComponent } from 'igniteui-angular';
@Component({
selector: 'app-icon-test',
templateUrl: './icon-test.component.html',
styleUrls: ['./icon-test.component.scss']
})
export class IconTestComponent {
@ViewChild(IgxIconComponent, { static: true })
private icon: IgxIconComponent;
constructor() {
const name = this.icon.getIconName;
const family = this.icon.getFontSet;
const color = this.icon.getIconColor;
}
}
@NgModule({
declarations: [IconTestComponent],
exports: [IconTestComponent],
imports: [IgxIconModule]
});
`);

const tree = await runner
.runSchematicAsync('migration-19', {}, appTree)
.toPromise();

const expectedContent = `import { Component, ViewChild } from '@angular/core';
import { IgxIconModule, IgxIconComponent } from 'igniteui-angular';
@Component({
selector: 'app-icon-test',
templateUrl: './icon-test.component.html',
styleUrls: ['./icon-test.component.scss']
})
export class IconTestComponent {
@ViewChild(IgxIconComponent, { static: true })
private icon: IgxIconComponent;
constructor() {
const name = this.icon.getName;
const family = this.icon.getFamily;
const color = this.icon.getColor;
}
}
@NgModule({
declarations: [IconTestComponent],
exports: [IconTestComponent],
imports: [IgxIconModule]
});
`;
console.log(tree.readContent(
'/testSrc/appPrefix/component/icon-test.component.ts'
));

expect(
tree.readContent(
'/testSrc/appPrefix/component/icon-test.component.ts'
)
).toEqual(expectedContent);
});
});

0 comments on commit 9b3ddde

Please sign in to comment.