diff --git a/packages/core/test/linker/change_detection_integration_spec.ts b/packages/core/test/linker/change_detection_integration_spec.ts index 3f3d5f5b20..606eb36061 100644 --- a/packages/core/test/linker/change_detection_integration_spec.ts +++ b/packages/core/test/linker/change_detection_integration_spec.ts @@ -589,7 +589,7 @@ const TEST_COMPILER_PROVIDERS: Provider[] = [ })); - modifiedInIvy('FW-821: Pure pipes are instantiated differently in view engine and ivy') + modifiedInIvy('Pure pipes are instantiated differently in view engine and ivy') .it('should call pure pipes that are used multiple times only when the arguments change and share state between pipe instances', fakeAsync(() => { const ctx = createCompFixture( diff --git a/packages/core/test/linker/view_injector_integration_spec.ts b/packages/core/test/linker/view_injector_integration_spec.ts index d9c5e6070c..53695651ea 100644 --- a/packages/core/test/linker/view_injector_integration_spec.ts +++ b/packages/core/test/linker/view_injector_integration_spec.ts @@ -10,7 +10,7 @@ import {Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, Compon import {ComponentFixture, TestBed, fakeAsync} from '@angular/core/testing'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {expect} from '@angular/platform-browser/testing/src/matchers'; -import {fixmeIvy, obsoleteInIvy, onlyInIvy} from '@angular/private/testing'; +import {fixmeIvy, modifiedInIvy, obsoleteInIvy, onlyInIvy} from '@angular/private/testing'; @Directive({selector: '[simpleDirective]'}) class SimpleDirective { @@ -292,19 +292,21 @@ class TestComp { expect(el.children[0].injector.get('injectable2')).toEqual('injectable1-injectable2'); }); - fixmeIvy('unknown').it('should instantiate viewProviders that have dependencies', () => { - TestBed.configureTestingModule({declarations: [SimpleComponent]}); - const viewProviders = [ - {provide: 'injectable1', useValue: 'injectable1'}, { - provide: 'injectable2', - useFactory: (val: any) => `${val}-injectable2`, - deps: ['injectable1'] - } - ]; - TestBed.overrideComponent(SimpleComponent, {set: {viewProviders}}); - const el = createComponent('
'); - expect(el.children[0].injector.get('injectable2')).toEqual('injectable1-injectable2'); - }); + fixmeIvy( + 'FW-889: Element injector cannot access the viewProviders of the component to which it belongs') + .it('should instantiate viewProviders that have dependencies', () => { + TestBed.configureTestingModule({declarations: [SimpleComponent]}); + const viewProviders = [ + {provide: 'injectable1', useValue: 'injectable1'}, { + provide: 'injectable2', + useFactory: (val: any) => `${val}-injectable2`, + deps: ['injectable1'] + } + ]; + TestBed.overrideComponent(SimpleComponent, {set: {viewProviders}}); + const el = createComponent(''); + expect(el.children[0].injector.get('injectable2')).toEqual('injectable1-injectable2'); + }); it('should instantiate components that depend on viewProviders providers', () => { TestBed.configureTestingModule({declarations: [NeedsServiceComponent]}); @@ -429,7 +431,7 @@ class TestComp { expect(ctx.debugElement.injector.get('eager2')).toBe('v2: v1'); }); - fixmeIvy('unknown').it('should inject providers that were declared after it', () => { + it('should inject providers that were declared after it', () => { @Component({ template: '', providers: [ @@ -465,52 +467,55 @@ class TestComp { expect(comp.componentInstance.a).toBe('aValue'); }); - fixmeIvy('unknown').it('should support ngOnDestroy for lazy providers', () => { - let created = false; - let destroyed = false; + fixmeIvy('FW-848: ngOnDestroy hooks are not called on providers') + .it('should support ngOnDestroy for lazy providers', () => { + let created = false; + let destroyed = false; - class SomeInjectable { - constructor() { created = true; } - ngOnDestroy() { destroyed = true; } - } + class SomeInjectable { + constructor() { created = true; } + ngOnDestroy() { destroyed = true; } + } - @Component({providers: [SomeInjectable], template: ''}) - class SomeComp { - } + @Component({providers: [SomeInjectable], template: ''}) + class SomeComp { + } - TestBed.configureTestingModule({declarations: [SomeComp]}); + TestBed.configureTestingModule({declarations: [SomeComp]}); - let compRef = TestBed.createComponent(SomeComp).componentRef; - expect(created).toBe(false); - expect(destroyed).toBe(false); + let compRef = TestBed.createComponent(SomeComp).componentRef; + expect(created).toBe(false); + expect(destroyed).toBe(false); - // no error if the provider was not yet created - compRef.destroy(); - expect(created).toBe(false); - expect(destroyed).toBe(false); + // no error if the provider was not yet created + compRef.destroy(); + expect(created).toBe(false); + expect(destroyed).toBe(false); - compRef = TestBed.createComponent(SomeComp).componentRef; - compRef.injector.get(SomeInjectable); - expect(created).toBe(true); - compRef.destroy(); - expect(destroyed).toBe(true); - }); + compRef = TestBed.createComponent(SomeComp).componentRef; + compRef.injector.get(SomeInjectable); + expect(created).toBe(true); + compRef.destroy(); + expect(destroyed).toBe(true); + }); - fixmeIvy('unknown').it('should instantiate view providers lazily', () => { - let created = false; - TestBed.configureTestingModule({declarations: [SimpleComponent]}); - TestBed.overrideComponent( - SimpleComponent, - {set: {viewProviders: [{provide: 'service', useFactory: () => created = true}]}}); - const el = createComponent(''); + fixmeIvy( + 'FW-889: Element injector cannot access the viewProviders of the component to which it belongs') + .it('should instantiate view providers lazily', () => { + let created = false; + TestBed.configureTestingModule({declarations: [SimpleComponent]}); + TestBed.overrideComponent( + SimpleComponent, + {set: {viewProviders: [{provide: 'service', useFactory: () => created = true}]}}); + const el = createComponent(''); - expect(created).toBe(false); + expect(created).toBe(false); - el.children[0].injector.get('service'); + el.children[0].injector.get('service'); - expect(created).toBe(true); - }); + expect(created).toBe(true); + }); it('should not instantiate other directives that depend on viewProviders providers (same element)', () => { @@ -552,8 +557,8 @@ class TestComp { .toEqual('parentService'); }); - fixmeIvy('unknown').it( - 'should instantiate directives that depend on providers of a component', () => { + fixmeIvy('FW-890: Overridden providers are not found during dependency resolution') + .it('should instantiate directives that depend on providers of a component', () => { TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]}); TestBed.overrideComponent( SimpleComponent, @@ -565,8 +570,8 @@ class TestComp { .toEqual('hostService'); }); - fixmeIvy('unknown').it( - 'should instantiate directives that depend on view providers of a component', () => { + fixmeIvy('FW-890: Overridden providers are not found during dependency resolution') + .it('should instantiate directives that depend on view providers of a component', () => { TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]}); TestBed.overrideComponent( SimpleComponent, @@ -578,19 +583,19 @@ class TestComp { .toEqual('hostService'); }); - fixmeIvy('unknown').it( - 'should instantiate directives in a root embedded view that depend on view providers of a component', - () => { - TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]}); - TestBed.overrideComponent( - SimpleComponent, - {set: {providers: [{provide: 'service', useValue: 'hostService'}]}}); - TestBed.overrideComponent( - SimpleComponent, {set: {template: ''}}); - const el = createComponent(''); - expect(el.children[0].children[0].injector.get(NeedsService).service) - .toEqual('hostService'); - }); + fixmeIvy('FW-890: Overridden providers are not found during dependency resolution') + .it('should instantiate directives in a root embedded view that depend on view providers of a component', + () => { + TestBed.configureTestingModule({declarations: [SimpleComponent, NeedsService]}); + TestBed.overrideComponent( + SimpleComponent, + {set: {providers: [{provide: 'service', useValue: 'hostService'}]}}); + TestBed.overrideComponent( + SimpleComponent, {set: {template: ''}}); + const el = createComponent(''); + expect(el.children[0].children[0].injector.get(NeedsService).service) + .toEqual('hostService'); + }); it('should instantiate directives that depend on instances in the app injector', () => { TestBed.configureTestingModule({declarations: [NeedsAppService]}); @@ -734,8 +739,8 @@ class TestComp { expect(d.dependency).toBeAnInstanceOf(SimpleComponent); }); - fixmeIvy('unknown').it( - 'should instantiate host views for components that have a @Host dependency ', () => { + obsoleteInIvy('@Host() / @Self() no longer looks in module injector') + .it('should instantiate host views for components that have a @Host dependency ', () => { TestBed.configureTestingModule({declarations: [NeedsHostAppService]}); const el = createComponent('', [], NeedsHostAppService); expect(el.componentInstance.service).toEqual('appService'); @@ -764,24 +769,25 @@ class TestComp { .toThrowError('NodeInjector: NOT_FOUND [SimpleDirective]'); }); - fixmeIvy('unknown').it( - 'should allow to use the NgModule injector from a root ViewContainerRef.parentInjector', - () => { - @Component({template: ''}) - class MyComp { - constructor(public vc: ViewContainerRef) {} - } + fixmeIvy('FW-638: Exception thrown when getting VCRef.parentInjector on the root view') + .it('should allow to use the NgModule injector from a root ViewContainerRef.parentInjector', + () => { + @Component({template: ''}) + class MyComp { + constructor(public vc: ViewContainerRef) {} + } - const compFixture = TestBed - .configureTestingModule({ - declarations: [MyComp], - providers: [{provide: 'someToken', useValue: 'someValue'}] - }) - .createComponent(MyComp); + const compFixture = + TestBed + .configureTestingModule({ + declarations: [MyComp], + providers: [{provide: 'someToken', useValue: 'someValue'}] + }) + .createComponent(MyComp); - expect(compFixture.componentInstance.vc.parentInjector.get('someToken')) - .toBe('someValue'); - }); + expect(compFixture.componentInstance.vc.parentInjector.get('someToken')) + .toBe('someValue'); + }); }); describe('static attributes', () => { @@ -812,23 +818,23 @@ class TestComp { .toBe(el.children[0].nativeElement); }); - fixmeIvy('unknown').it( - 'should inject ChangeDetectorRef of the component\'s view into the component', () => { - TestBed.configureTestingModule({declarations: [PushComponentNeedsChangeDetectorRef]}); - const cf = createComponentFixture(''); - cf.detectChanges(); - const compEl = cf.debugElement.children[0]; - const comp = compEl.injector.get(PushComponentNeedsChangeDetectorRef); - comp.counter = 1; - cf.detectChanges(); - expect(compEl.nativeElement).toHaveText('0'); - comp.changeDetectorRef.markForCheck(); - cf.detectChanges(); - expect(compEl.nativeElement).toHaveText('1'); - }); + it('should inject ChangeDetectorRef of the component\'s view into the component', () => { + TestBed.configureTestingModule({declarations: [PushComponentNeedsChangeDetectorRef]}); + const cf = createComponentFixture(''); + cf.detectChanges(); + const compEl = cf.debugElement.children[0]; + const comp = compEl.injector.get(PushComponentNeedsChangeDetectorRef); + comp.counter = 1; + cf.detectChanges(); + expect(compEl.nativeElement).toHaveText('0'); + comp.changeDetectorRef.markForCheck(); + cf.detectChanges(); + expect(compEl.nativeElement).toHaveText('1'); + }); - fixmeIvy('unknown').it( - 'should inject ChangeDetectorRef of the containing component into directives', () => { + fixmeIvy( + 'FW-893: expect(changeDetectorRef).toEqual(otherChangeDetectorRef) creates an infinite loop') + .it('should inject ChangeDetectorRef of the containing component into directives', () => { TestBed.configureTestingModule({ declarations: [PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef] @@ -858,51 +864,45 @@ class TestComp { expect(compEl.nativeElement).toHaveText('1'); }); - fixmeIvy('unknown').it( - 'should inject ChangeDetectorRef of a same element component into a directive', () => { - TestBed.configureTestingModule({ - declarations: - [PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef] - }); - const cf = createComponentFixture( - ''); - cf.detectChanges(); - const compEl = cf.debugElement.children[0]; - const comp = compEl.injector.get(PushComponentNeedsChangeDetectorRef); - const dir = compEl.injector.get(DirectiveNeedsChangeDetectorRef); - comp.counter = 1; - cf.detectChanges(); - expect(compEl.nativeElement).toHaveText('0'); - dir.changeDetectorRef.markForCheck(); - cf.detectChanges(); - expect(compEl.nativeElement).toHaveText('1'); - }); + it('should inject ChangeDetectorRef of a same element component into a directive', () => { + TestBed.configureTestingModule( + {declarations: [PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef]}); + const cf = createComponentFixture( + ''); + cf.detectChanges(); + const compEl = cf.debugElement.children[0]; + const comp = compEl.injector.get(PushComponentNeedsChangeDetectorRef); + const dir = compEl.injector.get(DirectiveNeedsChangeDetectorRef); + comp.counter = 1; + cf.detectChanges(); + expect(compEl.nativeElement).toHaveText('0'); + dir.changeDetectorRef.markForCheck(); + cf.detectChanges(); + expect(compEl.nativeElement).toHaveText('1'); + }); - fixmeIvy('unknown').it( - `should not inject ChangeDetectorRef of a parent element's component into a directive`, - () => { - TestBed - .configureTestingModule({ - declarations: - [PushComponentNeedsChangeDetectorRef, DirectiveNeedsChangeDetectorRef] - }) - .overrideComponent( - PushComponentNeedsChangeDetectorRef, - {set: {template: '