test(ivy): update test status for cases modified in ivy (#27652)

PR Close #27652
This commit is contained in:
Pawel Kozlowski 2018-12-13 15:18:51 +01:00 committed by Miško Hevery
parent 6b96931576
commit 0397e08153
2 changed files with 34 additions and 7 deletions

View File

@ -13,7 +13,7 @@ import {ComponentFixture, TestBed, fakeAsync} from '@angular/core/testing';
import {By} from '@angular/platform-browser/src/dom/debug/by'; import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {expect} from '@angular/platform-browser/testing/src/matchers'; import {expect} from '@angular/platform-browser/testing/src/matchers';
import {fixmeIvy} from '@angular/private/testing'; import {fixmeIvy, ivyEnabled, modifiedInIvy} from '@angular/private/testing';
export function createUrlResolverWithoutPackagePrefix(): UrlResolver { export function createUrlResolverWithoutPackagePrefix(): UrlResolver {
return new UrlResolver(); return new UrlResolver();
@ -589,8 +589,8 @@ const TEST_COMPILER_PROVIDERS: Provider[] = [
})); }));
fixmeIvy('FW-821: Pure pipes are instantiated differently in view engine and ivy') modifiedInIvy('FW-821: 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', .it('should call pure pipes that are used multiple times only when the arguments change and share state between pipe instances',
fakeAsync(() => { fakeAsync(() => {
const ctx = createCompFixture( const ctx = createCompFixture(
`<div [someProp]="name | countingPipe"></div><div [someProp]="age | countingPipe"></div>` + `<div [someProp]="name | countingPipe"></div><div [someProp]="age | countingPipe"></div>` +
@ -614,6 +614,33 @@ const TEST_COMPILER_PROVIDERS: Provider[] = [
]); ]);
})); }));
// this is the ivy version of the above tests - the difference is in pure pipe instantiation
// logic and binding execution order
ivyEnabled &&
it('should call pure pipes that are used multiple times only when the arguments change',
fakeAsync(() => {
const ctx = createCompFixture(
`<div [someProp]="name | countingPipe"></div><div [someProp]="age | countingPipe"></div>` +
'<div *ngFor="let x of [1,2]" [someProp]="address.city | countingPipe"></div>',
Person);
ctx.componentInstance.name = 'a';
ctx.componentInstance.age = 10;
ctx.componentInstance.address = new Address('mtv');
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([
'a state:0', '10 state:0', 'mtv state:0', 'mtv state:0'
]);
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([
'a state:0', '10 state:0', 'mtv state:0', 'mtv state:0'
]);
ctx.componentInstance.age = 11;
ctx.detectChanges(false);
expect(renderLog.loggedValues).toEqual([
'a state:0', '10 state:0', 'mtv state:0', 'mtv state:0', '11 state:1'
]);
}));
it('should call impure pipes on each change detection run', fakeAsync(() => { it('should call impure pipes on each change detection run', fakeAsync(() => {
const ctx = _bindSimpleValue('name | countingImpurePipe', Person); const ctx = _bindSimpleValue('name | countingImpurePipe', Person);
ctx.componentInstance.name = 'bob'; ctx.componentInstance.name = 'bob';

View File

@ -11,7 +11,7 @@ import {AfterContentInit, AfterViewInit, Component, ContentChildren, Directive,
import {TestBed} from '@angular/core/testing'; import {TestBed} from '@angular/core/testing';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {expect} from '@angular/platform-browser/testing/src/matchers'; import {expect} from '@angular/platform-browser/testing/src/matchers';
import {fixmeIvy, polyfillGoogGetMsg} from '@angular/private/testing'; import {fixmeIvy, modifiedInIvy, polyfillGoogGetMsg} from '@angular/private/testing';
if (ivyEnabled) { if (ivyEnabled) {
describe('ivy', () => { declareTests(); }); describe('ivy', () => { declareTests(); });
@ -52,7 +52,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(el).toHaveText('foo'); expect(el).toHaveText('foo');
}); });
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') modifiedInIvy('FW-678: ivy generates different DOM structure for <ng-container>')
.it('should be rendered as comment with children as siblings', () => { .it('should be rendered as comment with children as siblings', () => {
const template = '<ng-container><p></p></ng-container>'; const template = '<ng-container><p></p></ng-container>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -67,7 +67,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(getDOM().tagName(children[1]).toUpperCase()).toEqual('P'); expect(getDOM().tagName(children[1]).toUpperCase()).toEqual('P');
}); });
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') modifiedInIvy('FW-678: ivy generates different DOM structure for <ng-container>')
.it('should support nesting', () => { .it('should support nesting', () => {
const template = const template =
'<ng-container>1</ng-container><ng-container><ng-container>2</ng-container></ng-container>'; '<ng-container>1</ng-container><ng-container><ng-container>2</ng-container></ng-container>';
@ -86,7 +86,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(children[4]).toHaveText('2'); expect(children[4]).toHaveText('2');
}); });
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') modifiedInIvy('FW-678: ivy generates different DOM structure for <ng-container>')
.it('should group inner nodes', () => { .it('should group inner nodes', () => {
const template = '<ng-container *ngIf="ctxBoolProp"><p></p><b></b></ng-container>'; const template = '<ng-container *ngIf="ctxBoolProp"><p></p><b></b></ng-container>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});