feat(core): support for bootstrap with custom zone (#17672)
PR Close #17672
This commit is contained in:

committed by
Igor Minar

parent
6e1896b333
commit
344a5ca545
@ -16,8 +16,8 @@ import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
||||
import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {ServerModule} from '@angular/platform-server';
|
||||
|
||||
import {ComponentFixture, ComponentFixtureNoNgZone, TestBed, async, inject, withModule} from '../testing';
|
||||
import {NoopNgZone} from '../src/zone/ng_zone';
|
||||
import {ComponentFixtureNoNgZone, TestBed, async, inject, withModule} from '../testing';
|
||||
|
||||
@Component({selector: 'bootstrap-app', template: 'hello'})
|
||||
class SomeComponent {
|
||||
@ -287,6 +287,15 @@ export function main() {
|
||||
defaultPlatform.bootstrapModule(createModule({bootstrap: [SomeComponent]}))
|
||||
.then(module => expect((<any>defaultPlatform)._modules).toContain(module));
|
||||
}));
|
||||
|
||||
it('should bootstrap with NoopNgZone', async(() => {
|
||||
defaultPlatform
|
||||
.bootstrapModule(createModule({bootstrap: [SomeComponent]}), {ngZone: 'noop'})
|
||||
.then((module) => {
|
||||
const ngZone = module.injector.get(NgZone);
|
||||
expect(ngZone instanceof NoopNgZone).toBe(true);
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('bootstrapModuleFactory', () => {
|
||||
|
@ -6,11 +6,12 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {EventEmitter, NgZone} from '@angular/core';
|
||||
import {async, fakeAsync, flushMicrotasks} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter, Log, beforeEach, describe, expect, inject, it, xit} from '@angular/core/testing/src/testing_internal';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {scheduleMicroTask} from '../../src/util';
|
||||
import {NoopNgZone} from '../../src/zone/ng_zone';
|
||||
|
||||
const needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge;
|
||||
const resultTimer = 1000;
|
||||
@ -170,6 +171,25 @@ export function main() {
|
||||
}), testTimeout);
|
||||
});
|
||||
});
|
||||
|
||||
describe('NoopNgZone', () => {
|
||||
const ngZone = new NoopNgZone();
|
||||
|
||||
it('should run', () => {
|
||||
let runs = false;
|
||||
ngZone.run(() => {
|
||||
ngZone.runGuarded(() => { ngZone.runOutsideAngular(() => { runs = true; }); });
|
||||
});
|
||||
expect(runs).toBe(true);
|
||||
});
|
||||
|
||||
it('should have EventEmitter instances', () => {
|
||||
expect(ngZone.onError instanceof EventEmitter).toBe(true);
|
||||
expect(ngZone.onStable instanceof EventEmitter).toBe(true);
|
||||
expect(ngZone.onUnstable instanceof EventEmitter).toBe(true);
|
||||
expect(ngZone.onMicrotaskEmpty instanceof EventEmitter).toBe(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function commonTests() {
|
||||
|
Reference in New Issue
Block a user