本文整理匯總了TypeScript中angular2/platform/testing/browser.TEST_BROWSER_APPLICATION_PROVIDERS.concat方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TEST_BROWSER_APPLICATION_PROVIDERS.concat方法的具體用法?TypeScript TEST_BROWSER_APPLICATION_PROVIDERS.concat怎麽用?TypeScript TEST_BROWSER_APPLICATION_PROVIDERS.concat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular2/platform/testing/browser.TEST_BROWSER_APPLICATION_PROVIDERS
的用法示例。
在下文中一共展示了TEST_BROWSER_APPLICATION_PROVIDERS.concat方法的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({