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


TypeScript testing.setBaseTestProviders函數代碼示例

本文整理匯總了TypeScript中@angular/core/testing.setBaseTestProviders函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript setBaseTestProviders函數的具體用法?TypeScript setBaseTestProviders怎麽用?TypeScript setBaseTestProviders使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了setBaseTestProviders函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe('PersonsDetailsComponent', () => {
    if( !getTestInjector().platformProviders.length )
        setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS)
    
    let fixture: ComponentFixture<PersonsDetailsComponent>
    
    beforeEachProviders(() => [
        TestComponentBuilder,
        provide(Http, {useValue: {}})
    ])
    
    beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        return tcb
            .createAsync(PersonsDetailsComponent)
            .then(rootFixture => fixture = rootFixture)
    }))
    
    it('must be a list of persons list', () => {
        let component = fixture.componentInstance
        let element = fixture.nativeElement
        
        fixture.detectChanges()
        
        expect(element.querySelectorAll('li').length).toBe(5)
        expect(element.querySelector('li').innerText).toBe('Max Smith')
    })
})
開發者ID:pracxs,項目名稱:angular-2-sofia,代碼行數:27,代碼來源:details.component.spec.ts

示例2: describe

describe('GreeterComponent', () => {
    if( !getTestInjector().platformProviders.length )
        setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS)
    
    it('must be "Phone Book App"', 
        async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
            return tcb.createAsync(GreeterComponent)
                .then((fixture: ComponentFixture<GreeterComponent>) => {
                    let element = fixture.nativeElement

                    fixture.detectChanges()

                    expect(element.querySelectorAll('h1').length).toBe(1);
                    expect(element.querySelector('h1').innerText).toBe('Phone Book App');
                })
        }))
    )   
})
開發者ID:georgema1982,項目名稱:angular-2-intro,代碼行數:18,代碼來源:greeter.component.spec.ts

示例3: describe

describe('Router tests', () => {
  if( !getTestInjector().platformProviders.length )
    setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS)
  
  let router: Router
  let spylocation: SpyLocation
  
  //setup
  beforeEach(() => {
    addProviders([
      RouteRegistry,
      provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppComponent}),
      provide(Location, {useClass: SpyLocation}),
      provide(Router, {useClass: RootRouter}),
    ])
  })
  
  beforeEach(inject([Router, Location], (r, l) => {
    router = r
    spylocation = l
  }))
  
  //specs
  it('Should be able to navigate to Home', done => {
    router.navigate(['PersonList']).then(() => {
      expect(spylocation.path()).toBe('')
      done()
    }).catch(e => done.fail(e))
  })

  it('should redirect not registered urls to Home', done => {
    router.navigateByUrl('/unknown').then(() => {
      expect(spylocation.path()).toBe('')
      done()
    }).catch(e => done.fail(e))
  })
  
  it('Should be able to navigate to About', done => {    
    router.navigate(['About']).then(() => {
      expect(spylocation.path()).toBe('/about')
      done()
    }).catch(e => done.fail(e))
  })
})
開發者ID:georgema1982,項目名稱:angular-2-intro,代碼行數:44,代碼來源:router.spec.ts

示例4: setBaseTestProviders

/**
 * Created by najorcruzcruz on 14/7/16.
 */

import { setBaseTestProviders } from "@angular/core/testing";
import {
    TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS,
    TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
} from '@angular/platform-browser-dynamic/testing';

setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);

declare var ARCGIS_MODULE: any;

beforeAll(() => {
    ARCGIS_MODULE.getAddress = () => {
        return new Promise((fulfill, reject) => {
            fulfill({
                address: {
                    Match_addr: 'Super calle callejon'
                },
                location: {
                    latitude: -20.23,
                    longitude: 12.003
                }
            });
        })
    };
});

開發者ID:najor,項目名稱:ng2-md-arcgis,代碼行數:29,代碼來源:init.spec.ts

示例5: resetBaseTestProviders

import {BROWSER_APP_DYNAMIC_PROVIDERS} from "@angular/platform-browser-dynamic";
import {
  TEST_BROWSER_STATIC_PLATFORM_PROVIDERS,
  ADDITIONAL_TEST_BROWSER_PROVIDERS
} from "@angular/platform-browser/testing";
import {MATERIAL_BROWSER_PROVIDERS} from "../../index";
import {TestUrlResolver} from "./test_url_resolver";
import {UrlResolver} from "@angular/compiler";
import {provide, ApplicationRef} from "@angular/core";

resetBaseTestProviders();
setBaseTestProviders(
  TEST_BROWSER_STATIC_PLATFORM_PROVIDERS,
  [
    ...BROWSER_APP_DYNAMIC_PROVIDERS,
    ...ADDITIONAL_TEST_BROWSER_PROVIDERS,
    ...MATERIAL_BROWSER_PROVIDERS,
    provide(ApplicationRef, {useClass: MockApplicationRef}),
    provide(UrlResolver, {useValue: new TestUrlResolver()})
  ]
);

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();
開發者ID:13812453806,項目名稱:ng2-material,代碼行數:32,代碼來源:bootstrap.ts

示例6: setBaseTestProviders

'use strict';

import {setBaseTestProviders} from '@angular/core/testing';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { OptionsService, RedocEventsService, Hash, ScrollService, MenuService } from '../lib/services/index';
import { SpecManager } from '../lib/utils/SpecManager';
import { provide } from '@angular/core';

import {
  TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
  TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
} from '@angular/platform-browser-dynamic/testing';

setBaseTestProviders(
  [
    TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
    provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
    provide(OptionsService, {useClass: OptionsService}),
    provide(RedocEventsService, {useClass: RedocEventsService}),
    provide(SpecManager, {useClass: SpecManager}),
    provide(Hash, {useClass: Hash}),
    provide(ScrollService, {useClass: ScrollService}),
    provide(MenuService, {useClass: MenuService})
  ],
  [TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS]);
開發者ID:ajeetkanojia,項目名稱:ReDoc,代碼行數:25,代碼來源:setup.ts

示例7: resetBaseTestProviders

declare var Zone: any;


import {resetBaseTestProviders, setBaseTestProviders} from "@angular/core/testing";
import {BROWSER_APP_COMPILER_PROVIDERS} from "@angular/platform-browser-dynamic";
import {TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS} from "@angular/platform-browser-dynamic/testing";
import {MATERIAL_BROWSER_PROVIDERS} from "../../index";
import {TestUrlResolver} from "./test_url_resolver";
import {UrlResolver} from "@angular/compiler";

resetBaseTestProviders();
setBaseTestProviders(
  TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
  [
    ...BROWSER_APP_COMPILER_PROVIDERS,
    ...TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS,
    ...MATERIAL_BROWSER_PROVIDERS,
    {provide: UrlResolver, useValue: new TestUrlResolver()}
  ]
);

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();
開發者ID:Nightapes,項目名稱:ng2-material,代碼行數:31,代碼來源:bootstrap.ts

示例8: beforeEach

 beforeEach(() => {
   resetBaseTestProviders();
   setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
                       TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
   addProviders([ChessService, TestComponentBuilder]);
 });
開發者ID:isolani-chess,項目名稱:web-client,代碼行數:6,代碼來源:chess-board.component.spec.ts

示例9: setBaseTestProviders

/// <reference path="../../../typings/index.d.ts"/>
import 'zone.js/dist/zone';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import {todos, visibility} from './todos';
import * as types from '../constants/ActionTypes';
import * as filters from '../constants/TodoFilters';
import {describe, it, expect, setBaseTestProviders} from '@angular/core/testing';
import {TEST_BROWSER_STATIC_PLATFORM_PROVIDERS, ADDITIONAL_TEST_BROWSER_PROVIDERS} from '@angular/platform-browser/testing';
import {BROWSER_APP_DYNAMIC_PROVIDERS} from '@angular/platform-browser-dynamic';

setBaseTestProviders(
  TEST_BROWSER_STATIC_PLATFORM_PROVIDERS,
  [
    BROWSER_APP_DYNAMIC_PROVIDERS,
    ADDITIONAL_TEST_BROWSER_PROVIDERS
  ]
);
describe('Reducers', () => {
  describe('todo reducer', () => {
    it('should handle initial state', () => {
      expect(todos(undefined, {})).toEqual([
        {
          text: 'Use ngrx/store',
          completed: false,
          id: 0
        }
      ]);
    });

    it('should handle ADD_TODO', () => {
開發者ID:Delapouite,項目名稱:generator-fountain-angular2,代碼行數:31,代碼來源:todos.spec.ts

示例10: setBaseTestProviders

@Component({
    selector: 'game-board',
    template: ''
})
class MockGameBoard {}
@Component({
    selector: 'footer',
    template: ''
})
class MockFooter {}

setBaseTestProviders(
    TEST_BROWSER_STATIC_PLATFORM_PROVIDERS,
    [
        BROWSER_APP_DYNAMIC_PROVIDERS,
        ADDITIONAL_TEST_BROWSER_PROVIDERS,
        HTTP_PROVIDERS,
        MdIconRegistry,
        GameService
    ]
);
describe('app component', () => {
    it('should render the tool-bar, game-board and footer', async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
        tcb
            .overrideDirective(AppComponent, ToolBarComponent, MockToolBar)
            .overrideDirective(AppComponent, GameBoardComponent, MockGameBoard)
            .overrideDirective(AppComponent, FooterComponent, MockFooter)
            .createAsync(AppComponent)
            .then(fixture => {
                fixture.detectChanges();
                const main = fixture.nativeElement;
                expect(main.querySelector('ToolBarComponent')).toBeDefined();
開發者ID:HilmiDEV,項目名稱:ng2snake,代碼行數:32,代碼來源:app.component.spec.ts


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