test(ivy): update root causes for @angular/core TestBed failures (#27370)
PR Close #27370
This commit is contained in:
committed by
Igor Minar
parent
eb17502a7c
commit
1fa5478fef
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -192,13 +192,13 @@ class TestApp {
|
||||
});
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') && it('should list all child nodes', () => {
|
||||
it('should list all child nodes', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.childNodes.length).toEqual(3);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list all component child elements', () => {
|
||||
it('should list all component child elements', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
const childEls = fixture.debugElement.children;
|
||||
@@ -225,7 +225,7 @@ class TestApp {
|
||||
expect(getDOM().hasClass(childNested[0].nativeElement, 'childnested')).toBe(true);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list conditional component child elements', () => {
|
||||
it('should list conditional component child elements', () => {
|
||||
fixture = TestBed.createComponent(ConditionalParentComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -246,7 +246,7 @@ class TestApp {
|
||||
expect(conditionalContentComp.children.length).toEqual(1);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list child elements within viewports', () => {
|
||||
it('should list child elements within viewports', () => {
|
||||
fixture = TestBed.createComponent(UsingFor);
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -259,34 +259,37 @@ class TestApp {
|
||||
expect(list.children.length).toEqual(3);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list element attributes', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
fixmeIvy('FW-719: DebugElement needs proper implementation of its methods.') &&
|
||||
it('should list element attributes', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
|
||||
expect(bankElem.attributes['bank']).toEqual('RBC');
|
||||
expect(bankElem.attributes['account']).toEqual('4747');
|
||||
});
|
||||
expect(bankElem.attributes['bank']).toEqual('RBC');
|
||||
expect(bankElem.attributes['account']).toEqual('4747');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list element classes', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
fixmeIvy('FW-719: DebugElement needs proper implementation of its methods.') &&
|
||||
it('should list element classes', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
|
||||
expect(bankElem.classes['closed']).toBe(true);
|
||||
expect(bankElem.classes['open']).toBe(false);
|
||||
});
|
||||
expect(bankElem.classes['closed']).toBe(true);
|
||||
expect(bankElem.classes['open']).toBe(false);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list element styles', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
fixmeIvy('FW-719: DebugElement needs proper implementation of its methods.') &&
|
||||
it('should list element styles', () => {
|
||||
fixture = TestBed.createComponent(TestApp);
|
||||
fixture.detectChanges();
|
||||
const bankElem = fixture.debugElement.children[0];
|
||||
|
||||
expect(bankElem.styles['width']).toEqual('200px');
|
||||
expect(bankElem.styles['color']).toEqual('red');
|
||||
});
|
||||
expect(bankElem.styles['width']).toEqual('200px');
|
||||
expect(bankElem.styles['color']).toEqual('red');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should query child elements by css', () => {
|
||||
it('should query child elements by css', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -296,7 +299,7 @@ class TestApp {
|
||||
expect(getDOM().hasClass(childTestEls[0].nativeElement, 'child-comp-class')).toBe(true);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should query child elements by directive', () => {
|
||||
it('should query child elements by directive', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -309,39 +312,42 @@ class TestApp {
|
||||
expect(getDOM().hasClass(childTestEls[3].nativeElement, 'childnested')).toBe(true);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list providerTokens', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
fixmeIvy('FW-719: DebugElement needs proper implementation of its methods.') &&
|
||||
it('should list providerTokens', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.debugElement.providerTokens).toContain(Logger);
|
||||
});
|
||||
expect(fixture.debugElement.providerTokens).toContain(Logger);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list locals', () => {
|
||||
it('should list locals', () => {
|
||||
fixture = TestBed.createComponent(LocalsComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.debugElement.children[0].references !['alice']).toBeAnInstanceOf(MyDir);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should allow injecting from the element injector', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
fixmeIvy('FW-719: DebugElement needs proper implementation of its methods.') &&
|
||||
it('should allow injecting from the element injector', () => {
|
||||
fixture = TestBed.createComponent(ParentComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect((<Logger>(fixture.debugElement.children[0].injector.get(Logger))).logs).toEqual([
|
||||
'parent', 'nestedparent', 'child', 'nestedchild'
|
||||
]);
|
||||
});
|
||||
expect((<Logger>(fixture.debugElement.children[0].injector.get(Logger))).logs).toEqual([
|
||||
'parent', 'nestedparent', 'child', 'nestedchild'
|
||||
]);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should list event listeners', () => {
|
||||
fixture = TestBed.createComponent(EventsComp);
|
||||
fixture.detectChanges();
|
||||
fixmeIvy('FW-719: DebugElement needs proper implementation of its methods.') &&
|
||||
it('should list event listeners', () => {
|
||||
fixture = TestBed.createComponent(EventsComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.debugElement.children[0].listeners.length).toEqual(1);
|
||||
expect(fixture.debugElement.children[1].listeners.length).toEqual(1);
|
||||
expect(fixture.debugElement.children[0].listeners.length).toEqual(1);
|
||||
expect(fixture.debugElement.children[1].listeners.length).toEqual(1);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should trigger event handlers', () => {
|
||||
it('should trigger event handlers', () => {
|
||||
fixture = TestBed.createComponent(EventsComp);
|
||||
fixture.detectChanges();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,7 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
||||
import {dispatchEvent, el} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {fixmeIvy} from '@angular/private/testing';
|
||||
import {fixmeIvy, modifiedInIvy} from '@angular/private/testing';
|
||||
|
||||
import {stringify} from '../../src/util';
|
||||
|
||||
@@ -209,20 +209,21 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toEqual('Some other <div>HTML</div>');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should consume binding to className using class alias', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp]});
|
||||
const template = '<div class="initial" [class]="ctxProp"></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
modifiedInIvy('Binding to the class property directly works differently') &&
|
||||
it('should consume binding to className using class alias', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp]});
|
||||
const template = '<div class="initial" [class]="ctxProp"></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const nativeEl = fixture.debugElement.children[0].nativeElement;
|
||||
fixture.componentInstance.ctxProp = 'foo bar';
|
||||
fixture.detectChanges();
|
||||
const nativeEl = fixture.debugElement.children[0].nativeElement;
|
||||
fixture.componentInstance.ctxProp = 'foo bar';
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(nativeEl).toHaveCssClass('foo');
|
||||
expect(nativeEl).toHaveCssClass('bar');
|
||||
expect(nativeEl).not.toHaveCssClass('initial');
|
||||
});
|
||||
expect(nativeEl).toHaveCssClass('foo');
|
||||
expect(nativeEl).toHaveCssClass('bar');
|
||||
expect(nativeEl).not.toHaveCssClass('initial');
|
||||
});
|
||||
|
||||
it('should consume binding to htmlFor using for alias', () => {
|
||||
const template = '<label [for]="ctxProp"></label>';
|
||||
@@ -373,7 +374,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') &&
|
||||
modifiedInIvy('Comment node order changed') &&
|
||||
it('should support template directives via `<ng-template>` elements.', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, SomeViewport]});
|
||||
const template =
|
||||
@@ -401,7 +402,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(fixture.nativeElement).toHaveText('baz');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy(
|
||||
'FW-665: Discovery util fails with "Unable to find the given context data for the given target"') &&
|
||||
it('should not detach views in ViewContainers when the parent view is destroyed.', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, SomeViewport]});
|
||||
const template =
|
||||
@@ -565,7 +567,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('variables', () => {
|
||||
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') &&
|
||||
modifiedInIvy('Comment node order changed') &&
|
||||
it('should allow to use variables in a for loop', () => {
|
||||
const template =
|
||||
'<ng-template ngFor [ngForOf]="[1]" let-i><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</ng-template>';
|
||||
@@ -583,7 +585,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
|
||||
describe('OnPush components', () => {
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy(
|
||||
'FW-764: fixture.detectChanges() is not respecting OnPush flag on components in the root template') &&
|
||||
it('should use ChangeDetectorRef to manually request a check', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithRef]]]});
|
||||
const template = '<push-cmp-with-ref #cmp></push-cmp-with-ref>';
|
||||
@@ -604,23 +607,25 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should be checked when its bindings got updated', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]});
|
||||
const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
fixmeIvy(
|
||||
'FW-764: fixture.detectChanges() is not respecting OnPush flag on components in the root template') &&
|
||||
it('should be checked when its bindings got updated', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]});
|
||||
const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const cmp = fixture.debugElement.children[0].references !['cmp'];
|
||||
const cmp = fixture.debugElement.children[0].references !['cmp'];
|
||||
|
||||
fixture.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
fixture.componentInstance.ctxProp = 'one';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
fixture.componentInstance.ctxProp = 'two';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
});
|
||||
fixture.componentInstance.ctxProp = 'two';
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
});
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
fixmeIvy('unknown') &&
|
||||
@@ -643,43 +648,44 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
}));
|
||||
}
|
||||
|
||||
fixmeIvy('unknown') && it('should be checked when an event is fired', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]});
|
||||
const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
fixmeIvy('FW-758: OnPush events not marking view dirty when using renderer2') &&
|
||||
it('should be checked when an event is fired', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]});
|
||||
const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const cmpEl = fixture.debugElement.children[0];
|
||||
const cmp = cmpEl.componentInstance;
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
const cmpEl = fixture.debugElement.children[0];
|
||||
const cmp = cmpEl.componentInstance;
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(1);
|
||||
|
||||
// regular element
|
||||
cmpEl.children[0].triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
// regular element
|
||||
cmpEl.children[0].triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(2);
|
||||
|
||||
// element inside of an *ngIf
|
||||
cmpEl.children[1].triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(3);
|
||||
// element inside of an *ngIf
|
||||
cmpEl.children[1].triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(3);
|
||||
|
||||
// element inside a nested component
|
||||
cmpEl.children[2].children[0].triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(4);
|
||||
// element inside a nested component
|
||||
cmpEl.children[2].children[0].triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(4);
|
||||
|
||||
// host element
|
||||
cmpEl.triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(5);
|
||||
});
|
||||
// host element
|
||||
cmpEl.triggerEventHandler('click', <Event>{});
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
expect(cmp.numberOfChecks).toEqual(5);
|
||||
});
|
||||
|
||||
it('should not affect updating properties on the component', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithRef]]]});
|
||||
@@ -767,7 +773,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy(
|
||||
'FW-763: LView tree not properly constructed / destroyed for dynamically inserted components') &&
|
||||
it('should support events via EventEmitter on regular elements', async(() => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]});
|
||||
@@ -1490,7 +1497,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('error handling', () => {
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy('FW-682: TestBed: tests assert that compilation produces specific error') &&
|
||||
it('should report a meaningful error when a directive is missing annotation', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, SomeDirectiveMissingAnnotation]});
|
||||
@@ -1500,7 +1507,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
`Unexpected value '${stringify(SomeDirectiveMissingAnnotation)}' declared by the module 'DynamicTestModule'. Please add a @Pipe/@Directive/@Component annotation.`);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
fixmeIvy('FW-682: TestBed: tests assert that compilation produces specific error') &&
|
||||
it('should report a meaningful error when a component is missing view annotation', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, ComponentWithoutView]});
|
||||
try {
|
||||
@@ -1722,15 +1729,17 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toContain('"ng\-reflect\-ng\-if"\: "true"');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should indicate when toString() throws', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
|
||||
const template = '<div my-dir [elprop]="toStringThrow"></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
// also affected by FW-587: Inputs with aliases in component decorators don't work
|
||||
fixmeIvy('FW-664: ng-reflect-* is not supported') &&
|
||||
it('should indicate when toString() throws', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
|
||||
const template = '<div my-dir [elprop]="toStringThrow"></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(getDOM().getInnerHTML(fixture.nativeElement)).toContain('[ERROR]');
|
||||
});
|
||||
fixture.detectChanges();
|
||||
expect(getDOM().getInnerHTML(fixture.nativeElement)).toContain('[ERROR]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('property decorators', () => {
|
||||
|
||||
@@ -116,7 +116,7 @@ describe('TestBed', () => {
|
||||
expect(nameInjected).toEqual('World!');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should give access to the node injector for root node', () => {
|
||||
it('should give access to the node injector for root node', () => {
|
||||
const hello = TestBed.createComponent(HelloWorld);
|
||||
hello.detectChanges();
|
||||
const injector = hello.debugElement.injector;
|
||||
|
||||
@@ -117,7 +117,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
describe('deps', () => {
|
||||
class Dep {}
|
||||
|
||||
fixmeIvy('unknown') && it('should inject deps from the same element', () => {
|
||||
it('should inject deps from the same element', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 2, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, Dep, []),
|
||||
@@ -127,7 +127,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep instanceof Dep).toBeTruthy();
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should inject deps from a parent element', () => {
|
||||
it('should inject deps from a parent element', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 3, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, Dep, []),
|
||||
@@ -167,7 +167,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
' NullInjectorError: No provider for Dep!');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should inject from a parent element in a parent view', () => {
|
||||
it('should inject from a parent element in a parent view', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
0, NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
@@ -192,7 +192,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
' NullInjectorError: No provider for nonExistingDep!');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should use null for optional missing dependencies', () => {
|
||||
it('should use null for optional missing dependencies', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(
|
||||
@@ -202,7 +202,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep).toBe(null);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should skip the current element when using SkipSelf', () => {
|
||||
it('should skip the current element when using SkipSelf', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 4, 'span'),
|
||||
providerDef(NodeFlags.TypeValueProvider, null, 'someToken', 'someParentValue', []),
|
||||
@@ -214,19 +214,18 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep).toBe('someParentValue');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should ask the root injector',
|
||||
withModule({providers: [{provide: 'rootDep', useValue: 'rootValue'}]}, () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, ['rootDep'])
|
||||
]));
|
||||
it('should ask the root injector',
|
||||
withModule({providers: [{provide: 'rootDep', useValue: 'rootValue'}]}, () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, ['rootDep'])
|
||||
]));
|
||||
|
||||
expect(instance.dep).toBe('rootValue');
|
||||
}));
|
||||
expect(instance.dep).toBe('rootValue');
|
||||
}));
|
||||
|
||||
describe('builtin tokens', () => {
|
||||
fixmeIvy('unknown') && it('should inject ViewContainerRef', () => {
|
||||
it('should inject ViewContainerRef', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
anchorDef(NodeFlags.EmbeddedViews, null, null, 1),
|
||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, [ViewContainerRef]),
|
||||
@@ -235,7 +234,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep.createEmbeddedView).toBeTruthy();
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should inject TemplateRef', () => {
|
||||
it('should inject TemplateRef', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
anchorDef(NodeFlags.None, null, null, 1, null, compViewDefFactory([anchorDef(
|
||||
NodeFlags.None, null, null, 0)])),
|
||||
@@ -245,7 +244,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep.createEmbeddedView).toBeTruthy();
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should inject ElementRef', () => {
|
||||
it('should inject ElementRef', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, [ElementRef]),
|
||||
@@ -254,7 +253,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep.nativeElement).toBe(asElementData(view, 0).renderElement);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should inject Injector', () => {
|
||||
it('should inject Injector', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, [Injector]),
|
||||
@@ -263,32 +262,30 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep.get(SomeService)).toBe(instance);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should inject ChangeDetectorRef for non component providers', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, [ChangeDetectorRef])
|
||||
]));
|
||||
it('should inject ChangeDetectorRef for non component providers', () => {
|
||||
const {view} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, [ChangeDetectorRef])
|
||||
]));
|
||||
|
||||
expect(instance.dep._view).toBe(view);
|
||||
});
|
||||
expect(instance.dep._view).toBe(view);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should inject ChangeDetectorRef for component providers', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
0, NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
() => compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 0, 'span'),
|
||||
])),
|
||||
directiveDef(1, NodeFlags.Component, null, 0, SomeService, [ChangeDetectorRef]),
|
||||
]));
|
||||
it('should inject ChangeDetectorRef for component providers', () => {
|
||||
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
0, NodeFlags.None, null, null, 1, 'div', null, null, null, null,
|
||||
() => compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 0, 'span'),
|
||||
])),
|
||||
directiveDef(1, NodeFlags.Component, null, 0, SomeService, [ChangeDetectorRef]),
|
||||
]));
|
||||
|
||||
const compView = asElementData(view, 0).componentView;
|
||||
expect(instance.dep._view).toBe(compView);
|
||||
});
|
||||
const compView = asElementData(view, 0).componentView;
|
||||
expect(instance.dep._view).toBe(compView);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should inject RendererV1', () => {
|
||||
it('should inject RendererV1', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
0, NodeFlags.None, null, null, 1, 'span', null, null, null, null,
|
||||
@@ -299,7 +296,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep.createElement).toBeTruthy();
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should inject Renderer2', () => {
|
||||
it('should inject Renderer2', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
0, NodeFlags.None, null, null, 1, 'span', null, null, null, null,
|
||||
|
||||
Reference in New Issue
Block a user