當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript testing.resetBaseTestProviders函數代碼示例

本文整理匯總了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');
                });
        })
    );
});
開發者ID:abhinavmsra,項目名稱:angular2,代碼行數:56,代碼來源:employee-detail.component.spec.ts

示例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');
                });
        })
    );
});
開發者ID:abhinavmsra,項目名稱:angular2,代碼行數:52,代碼來源:employee-edit-form.component.spec.ts

示例3: afterAll

 afterAll(() => {
     resetBaseTestProviders();
 });
開發者ID:jepetko,項目名稱:mytunes,代碼行數:3,代碼來源:forRange.dir.spec.ts


注:本文中的angular2/testing.resetBaseTestProviders函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。