@@ -6,7 +6,7 @@
|
6 | 6 | * found in the LICENSE file at https://angular.io/license |
7 | 7 | */ |
8 | 8 | |
9 | | -import {ApplicationRef, COMPILER_OPTIONS, Component, destroyPlatform, NgModule, TestabilityRegistry, ViewEncapsulation} from '@angular/core'; |
| 9 | +import {ApplicationRef, COMPILER_OPTIONS, Component, destroyPlatform, NgModule, NgZone, TestabilityRegistry, ViewEncapsulation} from '@angular/core'; |
10 | 10 | import {expect} from '@angular/core/testing/src/testing_internal'; |
11 | 11 | import {BrowserModule} from '@angular/platform-browser'; |
12 | 12 | import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; |
@@ -227,6 +227,22 @@ describe('bootstrap', () => {
|
227 | 227 | })); |
228 | 228 | }); |
229 | 229 | |
| 230 | +describe('PlatformRef cleanup', () => { |
| 231 | +it('should unsubscribe from `onError` when Injector is destroyed', |
| 232 | +withBody('<my-app></my-app>', async () => { |
| 233 | +const TestModule = createComponentAndModule(); |
| 234 | + |
| 235 | +const ngModuleRef = await platformBrowserDynamic().bootstrapModule(TestModule); |
| 236 | +const ngZone = ngModuleRef.injector.get(NgZone); |
| 237 | + |
| 238 | +expect(ngZone.onError.observers.length).toBe(1); |
| 239 | + |
| 240 | +ngModuleRef.destroy(); |
| 241 | + |
| 242 | +expect(ngZone.onError.observers.length).toBe(0); |
| 243 | +})); |
| 244 | +}); |
| 245 | + |
230 | 246 | onlyInIvy('options cannot be changed in Ivy').describe('changing bootstrap options', () => { |
231 | 247 | beforeEach(() => { |
232 | 248 | spyOn(console, 'error'); |
@@ -365,4 +381,4 @@ export class MultipleSelectorsAppComponent {
|
365 | 381 | bootstrap: [MultipleSelectorsAppComponent], |
366 | 382 | }) |
367 | 383 | export class MultipleSelectorsAppModule { |
368 | | -} |
| 384 | +} |