-
Notifications
You must be signed in to change notification settings - Fork 24.8k
/
browser.ts
42 lines (38 loc) 路 1.21 KB
/
browser.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {PlatformLocation} from '@angular/common';
import {MockPlatformLocation} from '@angular/common/testing';
import {APP_ID, createPlatformFactory, NgModule, PLATFORM_INITIALIZER, platformCore, provideZoneChangeDetection, StaticProvider} from '@angular/core';
import {BrowserModule, 傻BrowserDomAdapter as BrowserDomAdapter} from '@angular/platform-browser';
function initBrowserTests() {
BrowserDomAdapter.makeCurrent();
}
const _TEST_BROWSER_PLATFORM_PROVIDERS: StaticProvider[] =
[{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}];
/**
* Platform for testing
*
* @publicApi
*/
export const platformBrowserTesting =
createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);
/**
* NgModule for testing.
*
* @publicApi
*/
@NgModule({
exports: [BrowserModule],
providers: [
{provide: APP_ID, useValue: 'a'},
provideZoneChangeDetection(),
{provide: PlatformLocation, useClass: MockPlatformLocation},
]
})
export class BrowserTestingModule {
}