本文整理匯總了TypeScript中angular2/testing.resetBaseTestProviders函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript resetBaseTestProviders函數的具體用法?TypeScript resetBaseTestProviders怎麽用?TypeScript resetBaseTestProviders使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了resetBaseTestProviders函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('Employee Detail Tests', () => {
resetBaseTestProviders();
setBaseTestProviders(
TEST_BROWSER_PLATFORM_PROVIDERS,
TEST_BROWSER_APPLICATION_PROVIDERS
);
beforeEachProviders(() => {
return [
ROUTER_DIRECTIVES,
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
EmployeeDetailServiceComponent,
EmployeeDeleteServiceComponent,
provide(XHRBackend, {useClass: MockBackend}),
provide(APP_BASE_HREF, {useValue: '/'}),
provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppComponent}),
provide(ApplicationRef, {useClass: MockApplicationRef}),
RouteRegistry,
provide(Location, {useClass: SpyLocation}),
provide(Router, {useClass: RootRouter}),
provide(RouteParams, { useValue: new RouteParams({ id: '1' }) })
]
});
it('Should display the list of employees',
injectAsync([XHRBackend, TestComponentBuilder], (backend, tcb) => {
backend.connections.subscribe(
(connection:MockConnection) => {
var options = new ResponseOptions({
body: {
"id": 1,
"name": "Roshan Shrestha"
}
});
var response = new Response(options);
connection.mockRespond(response);
}
);
return tcb
.createAsync(TestMyDetail)
.then((fixture) => {
fixture.detectChanges();
var compiled = fixture.nativeElement;
expect(compiled.innerHTML).toContain('Roshan Shrestha');
var src = (new BrowserDomAdapter()).getProperty(compiled.querySelector('a'), 'href');
// Employee link expectation
expect(src).toBe('http://localhost:9876/employee/1/edit');
});
})
);
});
示例2: describe
describe('Employee Edit Form Tests', () => {
resetBaseTestProviders();
setBaseTestProviders(
TEST_BROWSER_PLATFORM_PROVIDERS,
TEST_BROWSER_APPLICATION_PROVIDERS
);
beforeEachProviders(() => {
return [
ROUTER_DIRECTIVES,
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
EmployeeEditFormComponent,
EmployeeDetailServiceComponent,
EmployeeEditFormServiceComponent,
provide(XHRBackend, {useClass: MockBackend}),
provide(APP_BASE_HREF, {useValue: '/'}),
provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppComponent}),
provide(ApplicationRef, {useClass: MockApplicationRef}),
RouteRegistry,
provide(Location, {useClass: SpyLocation}),
provide(Router, {useClass: RootRouter}),
provide(RouteParams, { useValue: new RouteParams({ id: '1' }) })
]
});
it('Should display the edit form of employees',
injectAsync([XHRBackend, TestComponentBuilder], (backend, tcb) => {
backend.connections.subscribe(
(connection:MockConnection) => {
var options = new ResponseOptions({
body: {
"id": 1,
"name": "Roshan Shrestha"
}
});
var response = new Response(options);
connection.mockRespond(response);
}
);
return tcb
.createAsync(TestMyEditForm)
.then((fixture) => {
fixture.detectChanges();
var compiled = fixture.nativeElement;
expect(compiled.innerHTML).toContain('Employee Edit Form');
});
})
);
});
示例3: afterAll
afterAll(() => {
resetBaseTestProviders();
});