本文整理汇总了TypeScript中angular2/platform/testing/browser.TEST_BROWSER_APPLICATION_PROVIDERS类的典型用法代码示例。如果您正苦于以下问题:TypeScript TEST_BROWSER_APPLICATION_PROVIDERS类的具体用法?TypeScript TEST_BROWSER_APPLICATION_PROVIDERS怎么用?TypeScript TEST_BROWSER_APPLICATION_PROVIDERS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TEST_BROWSER_APPLICATION_PROVIDERS类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setBaseTestProviders
import 'es6-shim';
import 'zone.js';
import 'reflect-metadata';
import {setBaseTestProviders} from 'angular2/testing';
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser';
import {UrlResolver} from 'angular2/compiler';
import {provide} from 'angular2/core';
setBaseTestProviders(
TEST_BROWSER_PLATFORM_PROVIDERS,
TEST_BROWSER_APPLICATION_PROVIDERS.concat([
provide(UrlResolver, {useFactory: () => new FakeUrlResolver()})
])
);
class FakeUrlResolver extends UrlResolver {
constructor() {
super();
}
resolve(baseUrl: string, url: string): string {
// We do not attempt to load any CSS,
// as it is irrelevant during unit tests.
if (url.substr(-4) === '.css') {
return '';
}
return super.resolve(baseUrl, url);
}
}
示例2: onlySpecFiles
declare var System: any;
declare var Zone: any;
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from "angular2/platform/testing/browser";
import {setBaseTestProviders, MockApplicationRef} from "angular2/testing";
import {MATERIAL_PROVIDERS} from "../ng2-material/all";
import {TestUrlResolver} from "./test_url_resolver";
import {UrlResolver} from "angular2/compiler";
import {provide, ApplicationRef} from "angular2/core";
/**
* The providers for our tests
*/
const TEST_APP_PROVIDERS = TEST_BROWSER_APPLICATION_PROVIDERS.concat([
MATERIAL_PROVIDERS,
provide(ApplicationRef, { useClass: MockApplicationRef }),
provide(UrlResolver, {useValue: new TestUrlResolver()})
]);
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_APP_PROVIDERS);
function onlySpecFiles(path) {
return /_spec\.js$/.test(path);
}
export function load(files: string[]): Promise<any[]> {
console.log('importing test modules: ');
let error = (e: any) => {
console.error(e);
};
var myZone = new Zone();
示例3: onlySpecFiles
declare var System: any;
declare var Zone: any;
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from "angular2/platform/testing/browser";
import {setBaseTestProviders} from "angular2/testing";
import {MATERIAL_PROVIDERS} from "../ng2-material/all";
import {TestUrlResolver} from "./test_url_resolver";
import {UrlResolver} from "angular2/compiler";
import {provide} from "angular2/core";
/**
* The providers for our tests
*/
const TEST_APP_PROVIDERS = TEST_BROWSER_APPLICATION_PROVIDERS.concat([
MATERIAL_PROVIDERS,
provide(UrlResolver, {useValue: new TestUrlResolver()})
]);
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_APP_PROVIDERS);
function onlySpecFiles(path) {
return /_spec\.js$/.test(path);
}
export function load(files: string[]): Promise<any[]> {
console.log('importing test modules: ');
let error = (e: any) => {
console.error(e);
};
var myZone = new Zone();
myZone.fork({