mirror of
https://github.com/angular/angular.git
synced 2026-11-28 17:37:50 -05:00
test: add integration test for undecorated-classes-with-decorated-fields migration (#35339)
We don't have an integration test for the `undecorated-classes-with-decorated-fields migration. For consistency and to cover for the latest changes, we add it to the `ng update` integration test. PR Close #35339
This commit is contained in:
committed by
Kara Erickson
parent
5ff5a11509
commit
78211c42ea
+47
@@ -0,0 +1,47 @@
|
||||
import {Component, ElementRef, HostBinding, HostListener, Input, NgModule} from '@angular/core';
|
||||
|
||||
export class NonAngularBaseClass {
|
||||
greet() {}
|
||||
}
|
||||
|
||||
export class BaseClass extends NonAngularBaseClass {
|
||||
@Input() enabled = true;
|
||||
}
|
||||
|
||||
export class SecondBaseClass extends BaseClass {
|
||||
toggleEnabled() {
|
||||
this.enabled = !this.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
export class ThirdBaseClass extends SecondBaseClass {
|
||||
@HostListener('focus') onFocus() {}
|
||||
}
|
||||
|
||||
export class FourthBaseClass extends ThirdBaseClass {
|
||||
focus() {
|
||||
this.onFocus();
|
||||
}
|
||||
}
|
||||
|
||||
export class FifthBaseClass {
|
||||
constructor(private _elementRef: ElementRef) {}
|
||||
protected calculatePosition(): any {}
|
||||
}
|
||||
|
||||
export class MyCompSuperBase {
|
||||
@HostBinding('class.hello') hello = true;
|
||||
}
|
||||
|
||||
export class MyCompBase extends MyCompSuperBase {}
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
template: '',
|
||||
})
|
||||
export class MyComp extends MyCompBase {}
|
||||
|
||||
export class WrappedMyComp extends MyComp {}
|
||||
|
||||
@NgModule({declarations: [MyComp, WrappedMyComp]})
|
||||
export class TestModule {}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
import { Component, ElementRef, HostBinding, HostListener, Input, NgModule, Directive } from '@angular/core';
|
||||
|
||||
export class NonAngularBaseClass {
|
||||
greet() {}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class BaseClass extends NonAngularBaseClass {
|
||||
@Input() enabled = true;
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class SecondBaseClass extends BaseClass {
|
||||
toggleEnabled() {
|
||||
this.enabled = !this.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class ThirdBaseClass extends SecondBaseClass {
|
||||
@HostListener('focus') onFocus() {}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class FourthBaseClass extends ThirdBaseClass {
|
||||
focus() {
|
||||
this.onFocus();
|
||||
}
|
||||
}
|
||||
|
||||
export class FifthBaseClass {
|
||||
constructor(private _elementRef: ElementRef) {}
|
||||
protected calculatePosition(): any {}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class MyCompSuperBase {
|
||||
@HostBinding('class.hello') hello = true;
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class MyCompBase extends MyCompSuperBase {}
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
template: '',
|
||||
})
|
||||
export class MyComp extends MyCompBase {}
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
template: '',
|
||||
})
|
||||
export class WrappedMyComp extends MyComp {}
|
||||
|
||||
@NgModule({declarations: [MyComp, WrappedMyComp]})
|
||||
export class TestModule {}
|
||||
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -78,8 +78,7 @@ export class UndecoratedClassesWithDecoratedFieldsTransform {
|
||||
for (const {node: baseClass} of findBaseClassDeclarations(node, this.typeChecker)) {
|
||||
// If the undecorated class inherits from a decorated directive, skip the current class.
|
||||
// We do this because undecorated classes which inherit from directives/components are
|
||||
// handled as part of the the `undecorated-classes-with-di` migration which copies
|
||||
// inherited metadata.
|
||||
// handled in the `undecorated-classes-with-di` migration which copies inherited metadata.
|
||||
if (decoratedDirectives.has(baseClass)) {
|
||||
break;
|
||||
} else if (undecoratedDirectives.has(baseClass)) {
|
||||
|
||||
Reference in New Issue
Block a user