test(ivy): update root causes for @angular/core TestBed failures (#27479)

PR Close #27479
This commit is contained in:
Pawel Kozlowski
2018-12-05 11:24:06 -08:00
committed by Igor Minar
parent 26433509f9
commit 821fecb413
6 changed files with 755 additions and 734 deletions
+13 -14
View File
@@ -625,23 +625,22 @@ function declareTests(config?: {useJit: boolean}) {
});
if (getDOM().supportsDOMEvents()) {
fixmeIvy('unknown').it(
'should allow to destroy a component from within a host event handler',
fakeAsync(() => {
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithHostEvent]]]});
const template = '<push-cmp-with-host-event></push-cmp-with-host-event>';
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
it('should allow to destroy a component from within a host event handler',
fakeAsync(() => {
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithHostEvent]]]});
const template = '<push-cmp-with-host-event></push-cmp-with-host-event>';
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
tick();
fixture.detectChanges();
tick();
fixture.detectChanges();
const cmpEl = fixture.debugElement.children[0];
const cmp: PushCmpWithHostEvent = cmpEl.injector.get(PushCmpWithHostEvent);
cmp.ctxCallback = (_: any) => fixture.destroy();
const cmpEl = fixture.debugElement.children[0];
const cmp: PushCmpWithHostEvent = cmpEl.injector.get(PushCmpWithHostEvent);
cmp.ctxCallback = (_: any) => fixture.destroy();
expect(() => cmpEl.triggerEventHandler('click', <Event>{})).not.toThrow();
}));
expect(() => cmpEl.triggerEventHandler('click', <Event>{})).not.toThrow();
}));
}
fixmeIvy('FW-758: OnPush events not marking view dirty when using renderer2')
@@ -136,8 +136,8 @@ function declareTests(config?: {useJit: boolean}) {
expect(dir.text).toEqual('container');
});
fixmeIvy('unknown').it(
'should contain all direct child directives in a <ng-container> (content dom)', () => {
fixmeIvy('FW-795: Queries with descendants: true don\'t descent into <ng-container>')
.it('should contain all direct child directives in a <ng-container> (content dom)', () => {
const template =
'<needs-content-children #q><ng-container><div text="foo"></div></ng-container></needs-content-children>';
TestBed.overrideComponent(MyComp, {set: {template}});
File diff suppressed because it is too large Load Diff
@@ -9,7 +9,7 @@
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, Component, ContentChild, ContentChildren, Directive, QueryList, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef, asNativeElements} from '@angular/core';
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
import {expect} from '@angular/platform-browser/testing/src/matchers';
import {fixmeIvy, modifiedInIvy} from '@angular/private/testing';
import {fixmeIvy, ivyEnabled, modifiedInIvy} from '@angular/private/testing';
import {Subject} from 'rxjs';
import {stringify} from '../../src/util';
@@ -637,35 +637,66 @@ describe('Query API', () => {
expect(q.query.length).toBe(0);
});
fixmeIvy('unknown').it(
'should not throw if a content template is queried and created in the view during change detection',
() => {
@Component(
{selector: 'auto-projecting', template: '<div *ngIf="true; then: content"></div>'})
class AutoProjecting {
// TODO(issue/24571):
// remove '!'.
@ContentChild(TemplateRef)
content !: TemplateRef<any>;
modifiedInIvy('https://github.com/angular/angular/issues/15117 fixed in ivy')
.it('should not throw if a content template is queried and created in the view during change detection',
() => {
@Component({
selector: 'auto-projecting',
template: '<div *ngIf="true; then: content"></div>'
})
class AutoProjecting {
// TODO(issue/24571):
// remove '!'.
@ContentChild(TemplateRef)
content !: TemplateRef<any>;
// TODO(issue/24571):
// remove '!'.
@ContentChildren(TextDirective)
query !: QueryList<TextDirective>;
}
// TODO(issue/24571):
// remove '!'.
@ContentChildren(TextDirective)
query !: QueryList<TextDirective>;
}
TestBed.configureTestingModule({declarations: [AutoProjecting]});
const template =
'<auto-projecting #q><ng-template><div text="1"></div></ng-template></auto-projecting>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
TestBed.configureTestingModule({declarations: [AutoProjecting]});
const template =
'<auto-projecting #q><ng-template><div text="1"></div></ng-template></auto-projecting>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
const q = view.debugElement.children[0].references !['q'];
// This should be 1, but due to
// https://github.com/angular/angular/issues/15117
// this is 0.
expect(q.query.length).toBe(0);
});
const q = view.debugElement.children[0].references !['q'];
// This should be 1, but due to
// https://github.com/angular/angular/issues/15117
// this is 0.
expect(q.query.length).toBe(0);
});
if (ivyEnabled) {
// The fixed version of the "should not throw if a content template is queried and created in
// the view during change detection" test. This test is a different as ivy fixes
// https://github.com/angular/angular/issues/15117 present in the view engine.
it('should not throw if a content template is queried and created in the view during change detection - fixed in ivy',
() => {
@Component(
{selector: 'auto-projecting', template: '<div *ngIf="true; then: content"></div>'})
class AutoProjecting {
// TODO(issue/24571):
// remove '!'.
@ContentChild(TemplateRef)
content !: TemplateRef<any>;
// TODO(issue/24571):
// remove '!'.
@ContentChildren(TextDirective)
query !: QueryList<TextDirective>;
}
TestBed.configureTestingModule({declarations: [AutoProjecting]});
const template =
'<auto-projecting #q><ng-template><div text="1"></div></ng-template></auto-projecting>';
const view = createTestCmpAndDetectChanges(MyComp0, template);
const q = view.debugElement.children[0].references !['q'];
expect(q.query.length).toBe(1);
});
}
});
});
@@ -32,15 +32,16 @@ function declareTests(config?: {useJit: boolean}) {
describe('platform pipes', () => {
beforeEach(() => { TestBed.configureCompiler({...config}); });
fixmeIvy('unknown').it('should overwrite them by custom pipes', () => {
TestBed.configureTestingModule({declarations: [CustomPipe]});
const template = '{{true | somePipe}}';
TestBed.overrideComponent(MyComp1, {set: {template}});
const fixture = TestBed.createComponent(MyComp1);
fixmeIvy('FW-798: Handle pipes with duplicate names')
.it('should overwrite them by custom pipes', () => {
TestBed.configureTestingModule({declarations: [CustomPipe]});
const template = '{{true | somePipe}}';
TestBed.overrideComponent(MyComp1, {set: {template}});
const fixture = TestBed.createComponent(MyComp1);
fixture.detectChanges();
expect(fixture.nativeElement).toHaveText('someCustomPipe');
});
fixture.detectChanges();
expect(fixture.nativeElement).toHaveText('someCustomPipe');
});
});
describe('expressions', () => {
@@ -351,36 +352,37 @@ function declareTests(config?: {useJit: boolean}) {
});
});
fixmeIvy('unknown').it(
'should support @ContentChild and @Input on the same property for static queries', () => {
@Directive({selector: 'test'})
class Test {
// TODO(issue/24571): remove '!'.
@Input() @ContentChild(TemplateRef) tpl !: TemplateRef<any>;
}
fixmeIvy('FW-797: @ContentChildren results are assigned after @Input bindings')
.it('should support @ContentChild and @Input on the same property for static queries',
() => {
@Directive({selector: 'test'})
class Test {
// TODO(issue/24571): remove '!'.
@Input() @ContentChild(TemplateRef) tpl !: TemplateRef<any>;
}
@Component({
selector: 'my-app',
template: `
@Component({
selector: 'my-app',
template: `
<test></test><br>
<test><ng-template>Custom as a child</ng-template></test><br>
<ng-template #custom>Custom as a binding</ng-template>
<test [tpl]="custom"></test><br>
`
})
class App {
}
})
class App {
}
const fixture =
TestBed.configureTestingModule({declarations: [App, Test]}).createComponent(App);
fixture.detectChanges();
const fixture =
TestBed.configureTestingModule({declarations: [App, Test]}).createComponent(App);
fixture.detectChanges();
const testDirs =
fixture.debugElement.queryAll(By.directive(Test)).map(el => el.injector.get(Test));
expect(testDirs[0].tpl).toBeUndefined();
expect(testDirs[1].tpl).toBeDefined();
expect(testDirs[2].tpl).toBeDefined();
});
const testDirs = fixture.debugElement.queryAll(By.directive(Test))
.map(el => el.injector.get(Test));
expect(testDirs[0].tpl).toBeUndefined();
expect(testDirs[1].tpl).toBeDefined();
expect(testDirs[2].tpl).toBeDefined();
});
it('should not add ng-version for dynamically created components', () => {
@Component({template: ''})
File diff suppressed because it is too large Load Diff