From d1323b5c8f6e1e0ba26d695b68bd872f4a77d81d Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 17 Oct 2019 12:22:44 +0200 Subject: [PATCH] test: improve missing-injectable migration test case in ng-update integration test (#33223) Improves the `missing-injectable` migration test case in the `ng_update_migrations` integration test by adding scenarios for the recent changes that have been made to the migration. e.g. 5557dec120e3e81f5078089cb7821187fae501e0 PR Close #33223 --- .../migration-tests/providers-test-module.ts | 32 +++++++++++++++- .../providers-test-module_expected.ts | 37 ++++++++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/integration/ng_update_migrations/src/app/migration-tests/providers-test-module.ts b/integration/ng_update_migrations/src/app/migration-tests/providers-test-module.ts index 3c0e65522f..cf35d63f11 100644 --- a/integration/ng_update_migrations/src/app/migration-tests/providers-test-module.ts +++ b/integration/ng_update_migrations/src/app/migration-tests/providers-test-module.ts @@ -1,4 +1,30 @@ -import {Directive, NgModule, NgZone} from '@angular/core'; +import {Component, Directive, NgModule, NgZone} from '@angular/core'; + +export class ComponentTypeProvider {} +export class ComponentDontNeedCase {} +export class ComponentProvider {} +export class ComponentProvider2 {} + +@Component({ + template: '', + viewProviders: [ComponentTypeProvider, [ + {provide: ComponentDontNeedCase, useExisting: ComponentProvider}] + ], + providers: [ComponentProvider2] +}) +export class ProvidersTestComponent {} + +export class DirectiveTypeProvider {} +export class DirectiveDontNeedCase {} +export class DirectiveProvider {} + +@Directive({ + selector: 'test-dir', + providers: [DirectiveTypeProvider, [ + {provide: DirectiveDontNeedCase, useExisting: DirectiveProvider}] + ], +}) +export class ProvidersTestDirective {} export class TypeCase {} @@ -26,6 +52,8 @@ export class DirectiveCase {} {provide: DontNeedCase, useExisting: TypeCase}, {provide: DontNeedCase, useClass: ProviderClass}, DirectiveCase, - ] + ], + declarations: [ProvidersTestDirective, ProvidersTestComponent], }) export class ProvidersTestModule {} + diff --git a/integration/ng_update_migrations/src/app/migration-tests/providers-test-module_expected.ts b/integration/ng_update_migrations/src/app/migration-tests/providers-test-module_expected.ts index 9faa5120d1..c25fba964a 100644 --- a/integration/ng_update_migrations/src/app/migration-tests/providers-test-module_expected.ts +++ b/integration/ng_update_migrations/src/app/migration-tests/providers-test-module_expected.ts @@ -1,4 +1,35 @@ -import { Directive, NgModule, NgZone, Injectable } from '@angular/core'; +import { Component, Directive, NgModule, NgZone, Injectable } from '@angular/core'; + +@Injectable() +export class ComponentTypeProvider {} +export class ComponentDontNeedCase {} +@Injectable() +export class ComponentProvider {} +@Injectable() +export class ComponentProvider2 {} + +@Component({ + template: '', + viewProviders: [ComponentTypeProvider, [ + {provide: ComponentDontNeedCase, useExisting: ComponentProvider}] + ], + providers: [ComponentProvider2] +}) +export class ProvidersTestComponent {} + +@Injectable() +export class DirectiveTypeProvider {} +export class DirectiveDontNeedCase {} +@Injectable() +export class DirectiveProvider {} + +@Directive({ + selector: 'test-dir', + providers: [DirectiveTypeProvider, [ + {provide: DirectiveDontNeedCase, useExisting: DirectiveProvider}] + ], +}) +export class ProvidersTestDirective {} @Injectable() export class TypeCase {} @@ -30,6 +61,8 @@ export class DirectiveCase {} {provide: DontNeedCase, useExisting: TypeCase}, {provide: DontNeedCase, useClass: ProviderClass}, DirectiveCase, - ] + ], + declarations: [ProvidersTestDirective, ProvidersTestComponent], }) export class ProvidersTestModule {} +