当前位置: 首页>>代码示例>>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;未经允许,请勿转载。