fix(ivy): TestBed should use an NgZone (#27015)

PR Close #27015
This commit is contained in:
Kara Erickson 2018-11-08 15:57:17 -08:00 committed by Andrew Kushnir
parent 552836ebf0
commit 78b6f88cb3
3 changed files with 41 additions and 42 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Component, Directive, Injector, NgModule, Pipe, PlatformRef, Provider, RendererFactory2, SchemaMetadata, Type, ɵInjectableDef as InjectableDef, ɵNgModuleDef as NgModuleDef, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵRender3ComponentFactory as ComponentFactory, ɵRender3DebugRendererFactory2 as Render3DebugRendererFactory2, ɵRender3NgModuleRef as NgModuleRef, ɵWRAP_RENDERER_FACTORY2 as WRAP_RENDERER_FACTORY2, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵstringify as stringify} from '@angular/core'; import {Component, Directive, Injector, NgModule, NgZone, Pipe, PlatformRef, Provider, RendererFactory2, SchemaMetadata, Type, ɵInjectableDef as InjectableDef, ɵNgModuleDef as NgModuleDef, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵRender3ComponentFactory as ComponentFactory, ɵRender3DebugRendererFactory2 as Render3DebugRendererFactory2, ɵRender3NgModuleRef as NgModuleRef, ɵWRAP_RENDERER_FACTORY2 as WRAP_RENDERER_FACTORY2, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵstringify as stringify} from '@angular/core';
import {ComponentFixture} from './component_fixture'; import {ComponentFixture} from './component_fixture';
import {MetadataOverride} from './metadata_override'; import {MetadataOverride} from './metadata_override';
@ -361,7 +361,7 @@ export class TestBedRender3 implements Injector, TestBed {
const componentRef = const componentRef =
componentFactory.create(Injector.NULL, [], `#${rootElId}`, this._moduleRef); componentFactory.create(Injector.NULL, [], `#${rootElId}`, this._moduleRef);
const autoDetect: boolean = this.get(ComponentFixtureAutoDetect, false); const autoDetect: boolean = this.get(ComponentFixtureAutoDetect, false);
const fixture = new ComponentFixture<any>(componentRef, null, autoDetect); const fixture = new ComponentFixture<any>(componentRef, this.get(NgZone), autoDetect);
this._activeFixtures.push(fixture); this._activeFixtures.push(fixture);
return fixture; return fixture;
} }
@ -424,7 +424,9 @@ export class TestBedRender3 implements Injector, TestBed {
class RootScopeModule { class RootScopeModule {
} }
const providers = [...this._providers, ...this._providerOverrides]; const ngZone = new NgZone({enableLongStackTrace: true});
const providers =
[{provide: NgZone, useValue: ngZone}, ...this._providers, ...this._providerOverrides];
const declarations = this._declarations; const declarations = this._declarations;
const imports = [RootScopeModule, this.ngModule, this._imports]; const imports = [RootScopeModule, this.ngModule, this._imports];

View File

@ -149,7 +149,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
expect(form.value).toEqual({}); expect(form.value).toEqual({});
})); }));
fixmeIvy('whenStable not working') && fixmeIvy('host bindings do not yet work with classes or styles') &&
it('should set status classes with ngModel', async(() => { it('should set status classes with ngModel', async(() => {
const fixture = initTest(NgModelForm); const fixture = initTest(NgModelForm);
fixture.componentInstance.name = 'aa'; fixture.componentInstance.name = 'aa';
@ -176,7 +176,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
}); });
})); }));
fixmeIvy('whenStable not working') && fixmeIvy('host bindings do not yet work with classes or styles') &&
it('should set status classes with ngModel and async validators', fakeAsync(() => { it('should set status classes with ngModel and async validators', fakeAsync(() => {
const fixture = initTest(NgModelAsyncValidation, NgAsyncValidator); const fixture = initTest(NgModelAsyncValidation, NgAsyncValidator);
@ -204,7 +204,7 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
}); });
})); }));
fixmeIvy('whenStable not working') && fixmeIvy('host bindings do not yet work with classes or styles') &&
it('should set status classes with ngModelGroup and ngForm', async(() => { it('should set status classes with ngModelGroup and ngForm', async(() => {
const fixture = initTest(NgModelGroupForm); const fixture = initTest(NgModelGroupForm);
fixture.componentInstance.first = ''; fixture.componentInstance.first = '';
@ -1184,7 +1184,6 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
expect(input.nativeElement.disabled).toBe(true); expect(input.nativeElement.disabled).toBe(true);
})); }));
fixmeIvy('whenStable not working') &&
it('should disable a custom control if disabled attr is added', async(() => { it('should disable a custom control if disabled attr is added', async(() => {
const fixture = initTest(NgModelCustomWrapper, NgModelCustomComp); const fixture = initTest(NgModelCustomWrapper, NgModelCustomComp);
fixture.componentInstance.name = 'Nancy'; fixture.componentInstance.name = 'Nancy';

View File

@ -1059,7 +1059,6 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
describe('in template-driven forms', () => { describe('in template-driven forms', () => {
fixmeIvy('whenStable not working') &&
it('should support standard writing to view and model', async(() => { it('should support standard writing to view and model', async(() => {
const fixture = initTest(NgModelCustomWrapper, NgModelCustomComp); const fixture = initTest(NgModelCustomWrapper, NgModelCustomComp);
fixture.componentInstance.name = 'Nancy'; fixture.componentInstance.name = 'Nancy';
@ -1080,7 +1079,6 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
}); });
})); }));
}); });
}); });