本文整理汇总了TypeScript中angular2/testing.injectAsync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript injectAsync函数的具体用法?TypeScript injectAsync怎么用?TypeScript injectAsync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了injectAsync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('When loading the UserAppComponent', () => {
var mockRouterProvider: MockRouterProvider = new MockRouterProvider();
beforeEachProviders(() => {
return [mockRouterProvider.getProviders()];
});
it('should do something',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb
.createAsync(UserAppComponent)
.then((fixture: ComponentFixture) => {
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
});
})
);
});
开发者ID:aneagoie,项目名称:angular2-unit-test-app,代码行数:20,代码来源:user-app.component.spec.ts
示例2: describe
describe('AppComponent', () => {
beforeEachProviders(() => [
LoggerService,
ROUTER_PROVIDERS,
provide(ROUTER_PRIMARY_COMPONENT, { useValue: AppComponent }),
provide(ApplicationRef, { useClass: MockApplicationRef }),
provide(APP_BASE_HREF, { useValue: '/' }),
]);
it('should have brand Angular 2 Starter', injectAsync([TestComponentBuilder],
(tsb: TestComponentBuilder) => {
return tsb.createAsync(TestComponent).then((fixture) => {
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled).toBeDefined();
expect(compiled.querySelector('a.navbar-brand'))
.toHaveText('Angular 2 Starter');
});
}));
});
开发者ID:Darkniel,项目名称:angular2-zitio,代码行数:20,代码来源:app.component.spec.ts
示例3: describe
describe('App', () => {
let fixture: ComponentFixture;
beforeEach(injectAsync([TestComponentBuilder], tcb => {
return tcb.createAsync(App)
.then(f => fixture = f);
}));
it('should have a title', () => {
// given a component instance
let appCmp = fixture.componentInstance;
// when we trigger the change detection
fixture.detectChanges();
// then we should have a name
let element = fixture.nativeElement;
expect(element.querySelector('h1')).toHaveText('Hello, Angular2!');
});
});
开发者ID:gdangelo,项目名称:angular2-starter,代码行数:20,代码来源:app.spec.ts
示例4: describe
describe('Testing Login Component Failed Flow', () => {
let mockRouterProvider = new MockRouterProvider();
beforeEachProviders(() => {
return [
provide(AuthService, {useClass: MockFailedAuthService}),
mockRouterProvider.getProviders(),
FormBuilder
];
});
it('Login should fail', injectAsync([TestComponentBuilder],
(tcb: TestComponentBuilder) => {
return tcb.createAsync(LoginComponent).then(fixture => {
const instance = fixture.debugElement.componentInstance;
instance.login();
chai.expect(instance.message).to.equal('Incorrect credentials.');
});
}));
});
开发者ID:ManuCutillas,项目名称:ngCourse2,代码行数:20,代码来源:login.spec.ts
示例5: describe
describe('DashboardComponent', () => {
beforeEachProviders(() => [
provide(Router, { useValue: {} }),
provide(SpeakerService, {
useValue: {
getSpeakers: () => { },
onDbReset: () => { }
}}),
ToastService
]);
it('should instantiate component',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.createAsync(DashboardComponent).then(fixture => {
expect(fixture.componentInstance instanceof DashboardComponent).toBe(true, 'should create DashboardComponent');
});
}));
});
开发者ID:nickbarnettworks,项目名称:event-view,代码行数:20,代码来源:dashboard.component.spec.ts
示例6: describe
describe('Search Tests', () => {
beforeEachProviders(() => [
HTTP_PROVIDERS,
provide(MainService, { useClass: MockMainService })
]);
it('should change if active', injectAsync([TestComponentBuilder], (tcb) => {
return tcb
.overrideProviders(
Search, [provide(MainService, { useClass: MockMainService })]
)
.createAsync(Search).then((fixture) => {
fixture.componentInstance.search('url');
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled.outerHTML).toContain('TTT');
});
}));
});
开发者ID:astagi,项目名称:angular2-workbench,代码行数:21,代码来源:search.spec.ts
示例7: describe
describe('App component', () => {
// Support for testing component that uses Router
beforeEachProviders(() => [
RouteRegistry,
DirectiveResolver,
provide(Location, {useClass: SpyLocation}),
provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppComponent}),
provide(Router, {useClass: RootRouter})
]);
it('should work',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.createAsync(TestComponent)
.then(rootTC => {
rootTC.detectChanges();
let appDOMEl = rootTC.debugElement.children[0].nativeElement;
expect(DOM.querySelectorAll(appDOMEl, 'c-app > c-navbar > nav > a')[1].href).toMatch(/http:\/\/localhost:\d+\/about/);
});
}));
});
开发者ID:unit9,项目名称:gae-secure-scaffold-python,代码行数:21,代码来源:c-app.spec.ts
示例8: describe
describe('SampleComponent', () => {
let fixture;
//setup
beforeEachProviders(() => [
TestComponentBuilder
]);
beforeEach(injectAsync([TestComponentBuilder], tcb => {
return tcb
.createAsync(TestComponent)
.then(f => fixture = f);
}));
it('should say something about making a library', () => {
let container = fixture.componentInstance,
div = fixture.nativeElement.querySelector('div');
expect(div.textContent).toBe('');
});
});
开发者ID:jesperronn,项目名称:angular2-library-seed,代码行数:21,代码来源:sample.component.spec.ts
示例9: describe
describe('SanitizeDirective', () => {
let fixture;
//setup
beforeEachProviders(() => [
TestComponentBuilder
]);
beforeEach(injectAsync([TestComponentBuilder], tcb => {
return tcb
.createAsync(TestComponent)
.then(f => fixture = f);
}));
it('should add a class', () => {
let container = fixture.componentInstance,
div = fixture.nativeElement.querySelector('div');
expect(div.getAttribute('class')).toBe('sample-class');
});
});
开发者ID:NathanWalker,项目名称:ng2-sanitize,代码行数:21,代码来源:sanitize.directive.spec.ts
示例10: describe
describe('AppComponent', () => {
beforeEachProviders(() => [
AppComponent
]);
it('should exist', inject([AppComponent], (appComponent:AppComponent) => {
expect(appComponent).toBeDefined();
}));
it('should render a header', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
return tcb.createAsync(AppComponent)
.then((fixture:ComponentFixture) => {
let element = fixture.nativeElement;
let appComponent = fixture.componentInstance;
fixture.detectChanges();
expect(element.querySelectorAll('h1').length).toBe(1);
});
}));
});
开发者ID:Georg-W,项目名称:angular2-tdd-boilerplate,代码行数:21,代码来源:app.component.spec.ts
注:本文中的angular2/testing.injectAsync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论