test: add integration test for missing-injectable migration (#32349)
Adds a new test to the `ng_update_migrations` that ensures that the `missing-injectable` migration works properly in a real CLI project. Additionally this ensures that the `missing-injectable` and `undecorated-classes-with-di` migrations play nicely together. PR Close #32349
This commit is contained in:
parent
7fb3cc07de
commit
b48dd52494
|
@ -0,0 +1,31 @@
|
||||||
|
import {Directive, NgModule, NgZone} from '@angular/core';
|
||||||
|
|
||||||
|
export class TypeCase {}
|
||||||
|
|
||||||
|
// undecorated-classes-with-di migration will add "@Injectable" here
|
||||||
|
// because the constructor is inherited in "ProvideCase".
|
||||||
|
class BaseProviderCase {
|
||||||
|
constructor(zone: NgZone) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ProvideCase extends BaseProviderCase {}
|
||||||
|
|
||||||
|
export class ProviderClass {}
|
||||||
|
|
||||||
|
export class DontNeedCase {}
|
||||||
|
|
||||||
|
@Directive()
|
||||||
|
export class DirectiveCase {}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
providers: [
|
||||||
|
TypeCase,
|
||||||
|
{provide: ProvideCase},
|
||||||
|
{provide: DontNeedCase, useValue: 0},
|
||||||
|
{provide: DontNeedCase, useFactory: () => null},
|
||||||
|
{provide: DontNeedCase, useExisting: TypeCase},
|
||||||
|
{provide: DontNeedCase, useClass: ProviderClass},
|
||||||
|
DirectiveCase,
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class ProvidersTestModule {}
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { Directive, NgModule, NgZone, Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TypeCase {}
|
||||||
|
|
||||||
|
// undecorated-classes-with-di migration will add "@Injectable" here
|
||||||
|
// because the constructor is inherited in "ProvideCase".
|
||||||
|
@Injectable()
|
||||||
|
class BaseProviderCase {
|
||||||
|
constructor(zone: NgZone) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ProvideCase extends BaseProviderCase {}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ProviderClass {}
|
||||||
|
|
||||||
|
export class DontNeedCase {}
|
||||||
|
|
||||||
|
@Directive()
|
||||||
|
export class DirectiveCase {}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
providers: [
|
||||||
|
TypeCase,
|
||||||
|
{provide: ProvideCase},
|
||||||
|
{provide: DontNeedCase, useValue: 0},
|
||||||
|
{provide: DontNeedCase, useFactory: () => null},
|
||||||
|
{provide: DontNeedCase, useExisting: TypeCase},
|
||||||
|
{provide: DontNeedCase, useClass: ProviderClass},
|
||||||
|
DirectiveCase,
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class ProvidersTestModule {}
|
Loading…
Reference in New Issue