Files
angular-docs-cn/modules/@angular/platform-browser/testing/browser.ts
T

45 lines
1.3 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright Google Inc. 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
*/
2016-09-27 17:12:25 -07:00
import {APP_ID, NgModule, NgZone, PLATFORM_INITIALIZER, PlatformRef, Provider, createPlatformFactory, platformCore} from '@angular/core';
import {AnimationDriver, BrowserModule} from '@angular/platform-browser';
2016-06-08 16:38:52 -07:00
import {BrowserDetection, createNgZone} from './browser_util';
import {BrowserDomAdapter, ELEMENT_PROBE_PROVIDERS} from './private_import_platform-browser';
2016-06-08 16:38:52 -07:00
function initBrowserTests() {
BrowserDomAdapter.makeCurrent();
BrowserDetection.setup();
}
const _TEST_BROWSER_PLATFORM_PROVIDERS: Provider[] =
2016-07-18 03:50:31 -07:00
[{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}];
/**
2016-07-04 09:37:30 -07:00
* Platform for testing
*
* @stable
*/
export const platformBrowserTesting =
createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);
/**
2016-07-18 03:50:31 -07:00
* NgModule for testing.
*
* @stable
*/
2016-07-18 03:50:31 -07:00
@NgModule({
exports: [BrowserModule],
2016-07-04 09:37:30 -07:00
providers: [
{provide: APP_ID, useValue: 'a'}, ELEMENT_PROBE_PROVIDERS,
{provide: NgZone, useFactory: createNgZone},
{provide: AnimationDriver, useValue: AnimationDriver.NOOP}
]
})
2016-07-18 03:50:31 -07:00
export class BrowserTestingModule {
2016-07-04 09:37:30 -07:00
}