test: add integration test for undecorated-classes-with-di migration (#32349)
Adds tests for the `undecorated-classes-with-di` migration to the `ng_update_migrations` integration test. PR Close #32349
This commit is contained in:
parent
b48dd52494
commit
288e5d894d
|
@ -0,0 +1,24 @@
|
|||
import {Component, NgModule} from '@angular/core';
|
||||
import {NG_ASYNC_VALIDATORS} from '@angular/forms';
|
||||
|
||||
export const hostBindings = {
|
||||
class: 'test-base-comp',
|
||||
};
|
||||
|
||||
const nonExportedStyleUrlsVar = ['./base-component.css'];
|
||||
|
||||
@Component({
|
||||
selector: 'base-comp',
|
||||
template: `
|
||||
<span>This is the template.</span>
|
||||
`,
|
||||
host: hostBindings,
|
||||
styleUrls: nonExportedStyleUrlsVar,
|
||||
providers: [
|
||||
{provide: NG_ASYNC_VALIDATORS, useValue: null},
|
||||
]
|
||||
})
|
||||
export class BaseComponentFromOtherFile {}
|
||||
|
||||
@NgModule({declarations: [BaseComponentFromOtherFile]})
|
||||
export class BaseComponentModule {}
|
|
@ -0,0 +1,42 @@
|
|||
import {Directive, NgModule, NgZone} from '@angular/core';
|
||||
|
||||
export class BaseClass1 {
|
||||
constructor(zone: NgZone) {}
|
||||
}
|
||||
|
||||
@Directive({selector: 'sel'})
|
||||
export class DirectiveWithInheritedCtor extends BaseClass1 {}
|
||||
|
||||
export class BaseClass2 {
|
||||
constructor(zone: NgZone) {}
|
||||
}
|
||||
|
||||
@Directive({selector: 'sel'})
|
||||
export class DirectiveWithExplicitCtor extends BaseClass2 {
|
||||
constructor(zone: NgZone) {
|
||||
super(zone);
|
||||
}
|
||||
}
|
||||
|
||||
export class BaseClassWithoutCtor {}
|
||||
|
||||
@Directive({selector: 'sel'})
|
||||
export class DirectiveWithoutInheritedCtor extends BaseClassWithoutCtor {}
|
||||
|
||||
export class BaseClass3 {
|
||||
constructor(zone: NgZone) {}
|
||||
}
|
||||
export class PassThroughClass extends BaseClass3 {}
|
||||
|
||||
@Directive({selector: 'sel'})
|
||||
export class DirectiveWithInheritedCtorAndClassesInBetween extends PassThroughClass {}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
DirectiveWithInheritedCtor,
|
||||
DirectiveWithoutInheritedCtor,
|
||||
DirectiveWithExplicitCtor,
|
||||
DirectiveWithInheritedCtorAndClassesInBetween,
|
||||
]
|
||||
})
|
||||
export class TestModule {}
|
|
@ -0,0 +1,45 @@
|
|||
import {Directive, NgModule, NgZone} from '@angular/core';
|
||||
|
||||
@Directive()
|
||||
export class BaseClass1 {
|
||||
constructor(zone: NgZone) {}
|
||||
}
|
||||
|
||||
@Directive({selector: 'sel'})
|
||||
export class DirectiveWithInheritedCtor extends BaseClass1 {}
|
||||
|
||||
export class BaseClass2 {
|
||||
constructor(zone: NgZone) {}
|
||||
}
|
||||
|
||||
@Directive({selector: 'sel'})
|
||||
export class DirectiveWithExplicitCtor extends BaseClass2 {
|
||||
constructor(zone: NgZone) {
|
||||
super(zone);
|
||||
}
|
||||
}
|
||||
|
||||
export class BaseClassWithoutCtor {}
|
||||
|
||||
@Directive({selector: 'sel'})
|
||||
export class DirectiveWithoutInheritedCtor extends BaseClassWithoutCtor {}
|
||||
|
||||
@Directive()
|
||||
export class BaseClass3 {
|
||||
constructor(zone: NgZone) {}
|
||||
}
|
||||
@Directive()
|
||||
export class PassThroughClass extends BaseClass3 {}
|
||||
|
||||
@Directive({selector: 'sel'})
|
||||
export class DirectiveWithInheritedCtorAndClassesInBetween extends PassThroughClass {}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
DirectiveWithInheritedCtor,
|
||||
DirectiveWithoutInheritedCtor,
|
||||
DirectiveWithExplicitCtor,
|
||||
DirectiveWithInheritedCtorAndClassesInBetween,
|
||||
]
|
||||
})
|
||||
export class TestModule {}
|
|
@ -0,0 +1,31 @@
|
|||
import {Directive, NgModule, NgZone} from '@angular/core';
|
||||
import {CheckboxControlValueAccessor} from '@angular/forms';
|
||||
import {BaseComponentFromOtherFile} from './base-component';
|
||||
|
||||
|
||||
@Directive({
|
||||
selector: 'my-base-dir',
|
||||
providers: [{provide: NgZone, useValue: null}]
|
||||
})
|
||||
export class BaseDirective {}
|
||||
|
||||
export class DerivedDirective extends BaseDirective {}
|
||||
|
||||
export class DerivedDirectiveFromNodeModules extends CheckboxControlValueAccessor {}
|
||||
|
||||
export class DerivedComponentFromOtherSourceFile extends BaseComponentFromOtherFile {}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
DerivedDirective,
|
||||
DerivedDirectiveFromNodeModules,
|
||||
DerivedComponentFromOtherSourceFile,
|
||||
],
|
||||
})
|
||||
export class TestModule {}
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [BaseDirective],
|
||||
})
|
||||
export class BaseClassesModule {}
|
|
@ -0,0 +1,62 @@
|
|||
import { Directive, NgModule, NgZone, Component } from '@angular/core';
|
||||
import { CheckboxControlValueAccessor, NG_VALUE_ACCESSOR, NG_ASYNC_VALIDATORS } from '@angular/forms';
|
||||
import { BaseComponentFromOtherFile, hostBindings } from './base-component';
|
||||
|
||||
|
||||
@Directive({
|
||||
selector: 'my-base-dir',
|
||||
providers: [{provide: NgZone, useValue: null}]
|
||||
})
|
||||
export class BaseDirective {}
|
||||
|
||||
@Directive({
|
||||
selector: 'my-base-dir',
|
||||
providers: [{ provide: NgZone, useValue: null }]
|
||||
})
|
||||
export class DerivedDirective extends BaseDirective {}
|
||||
|
||||
@Directive({
|
||||
selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]",
|
||||
host: {
|
||||
"(change)": "onChange($event.target.checked)",
|
||||
"(blur)": "onTouched()"
|
||||
},
|
||||
providers: [{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: CheckboxControlValueAccessor,
|
||||
multi: true
|
||||
}]
|
||||
})
|
||||
export class DerivedDirectiveFromNodeModules extends CheckboxControlValueAccessor {}
|
||||
|
||||
@Component({
|
||||
selector: 'base-comp',
|
||||
template: `
|
||||
<span>This is the template.</span>
|
||||
`,
|
||||
host: hostBindings,
|
||||
providers: [
|
||||
{ provide: NG_ASYNC_VALIDATORS, useValue: null },
|
||||
],
|
||||
// The following fields were copied from the base class,
|
||||
// but could not be updated automatically to work in the
|
||||
// new file location. Please add any required imports for
|
||||
// the properties below:
|
||||
styleUrls: nonExportedStyleUrlsVar
|
||||
})
|
||||
export class DerivedComponentFromOtherSourceFile extends BaseComponentFromOtherFile {}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
DerivedDirective,
|
||||
DerivedDirectiveFromNodeModules,
|
||||
DerivedComponentFromOtherSourceFile,
|
||||
],
|
||||
})
|
||||
export class TestModule {}
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [BaseDirective],
|
||||
})
|
||||
export class BaseClassesModule {}
|
Loading…
Reference in New Issue