test(ivy): remove `new Component` use from inheritance tests (#30522)

PR Close #30522
This commit is contained in:
Ben Lesh 2019-05-16 12:51:57 -07:00 committed by Jason Aden
parent eda09e69ea
commit 80d4fc5e26
1 changed files with 52 additions and 28 deletions

View File

@ -43,10 +43,6 @@ describe('inheritance', () => {
}); });
describe('ngOnChanges', () => { describe('ngOnChanges', () => {
@Component({selector: 'app-comp', template: ``})
class AppComp {
}
it('should be inherited when super is a directive', () => { it('should be inherited when super is a directive', () => {
const log: string[] = []; const log: string[] = [];
@ -61,10 +57,14 @@ describe('inheritance', () => {
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
} }
TestBed.configureTestingModule({declarations: [AppComp, SubDirective]}); @Component({template: `<div subDir [someInput]="1"></div>`})
TestBed.overrideComponent( class App {
AppComp, {set: new Component({template: '<div subDir [someInput]="1"></div>'})}); }
const fixture = TestBed.createComponent(AppComp);
TestBed.configureTestingModule({
declarations: [App, SubDirective, SuperDirective],
});
const fixture = TestBed.createComponent(App);
fixture.detectChanges(); fixture.detectChanges();
expect(log).toEqual(['on changes!']); expect(log).toEqual(['on changes!']);
@ -82,10 +82,14 @@ describe('inheritance', () => {
@Input() someInput = ''; @Input() someInput = '';
} }
TestBed.configureTestingModule({declarations: [AppComp, SubDirective]}); @Component({template: `<div subDir [someInput]="1"></div>`})
TestBed.overrideComponent( class App {
AppComp, {set: new Component({template: '<div subDir [someInput]="1"></div>'})}); }
const fixture = TestBed.createComponent(AppComp);
TestBed.configureTestingModule({
declarations: [App, SubDirective],
});
const fixture = TestBed.createComponent(App);
fixture.detectChanges(); fixture.detectChanges();
expect(log).toEqual(['on changes!']); expect(log).toEqual(['on changes!']);
@ -109,10 +113,15 @@ describe('inheritance', () => {
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
} }
TestBed.configureTestingModule({declarations: [AppComp, SubDirective]});
TestBed.overrideComponent( @Component({template: `<div subDir [someInput]="1"></div>`})
AppComp, {set: new Component({template: '<div subDir [someInput]="1"></div>'})}); class App {
const fixture = TestBed.createComponent(AppComp); }
TestBed.configureTestingModule({
declarations: [App, SubDirective, SuperDirective, GrandSuperDirective],
});
const fixture = TestBed.createComponent(App);
fixture.detectChanges(); fixture.detectChanges();
expect(log).toEqual(['on changes!']); expect(log).toEqual(['on changes!']);
@ -134,10 +143,15 @@ describe('inheritance', () => {
class SubDirective extends SuperDirective { class SubDirective extends SuperDirective {
} }
TestBed.configureTestingModule({declarations: [AppComp, SubDirective]});
TestBed.overrideComponent( @Component({template: `<div subDir [someInput]="1"></div>`})
AppComp, {set: new Component({template: '<div subDir [someInput]="1"></div>'})}); class App {
const fixture = TestBed.createComponent(AppComp); }
TestBed.configureTestingModule({
declarations: [App, SubDirective, SuperDirective],
});
const fixture = TestBed.createComponent(App);
fixture.detectChanges(); fixture.detectChanges();
expect(log).toEqual(['on changes!']); expect(log).toEqual(['on changes!']);
@ -159,10 +173,15 @@ describe('inheritance', () => {
class SubDirective extends SuperClass { class SubDirective extends SuperClass {
} }
TestBed.configureTestingModule({declarations: [AppComp, SubDirective]});
TestBed.overrideComponent( @Component({template: `<div subDir [someInput]="1"></div>`})
AppComp, {set: new Component({template: '<div subDir [someInput]="1"></div>'})}); class App {
const fixture = TestBed.createComponent(AppComp); }
TestBed.configureTestingModule({
declarations: [App, SubDirective, GrandSuperDirective],
});
const fixture = TestBed.createComponent(App);
fixture.detectChanges(); fixture.detectChanges();
expect(log).toEqual(['on changes!']); expect(log).toEqual(['on changes!']);
@ -182,10 +201,15 @@ describe('inheritance', () => {
@Input() someInput = ''; @Input() someInput = '';
} }
TestBed.configureTestingModule({declarations: [AppComp, SubDirective]});
TestBed.overrideComponent( @Component({template: `<div subDir [someInput]="1"></div>`})
AppComp, {set: new Component({template: '<div subDir [someInput]="1"></div>'})}); class App {
const fixture = TestBed.createComponent(AppComp); }
TestBed.configureTestingModule({
declarations: [App, SubDirective],
});
const fixture = TestBed.createComponent(App);
fixture.detectChanges(); fixture.detectChanges();
expect(log).toEqual(['on changes!']); expect(log).toEqual(['on changes!']);