本文整理汇总了TypeScript中@angular/core/testing.injectAsync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript injectAsync函数的具体用法?TypeScript injectAsync怎么用?TypeScript injectAsync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了injectAsync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('UserService Service', () => {
beforeEachProviders(() => [API_PROVIDERS]);
it('should contain persisted model methods',
inject([RoomApi], (service: RoomApi) => {
expect(service).toBeTruthy();
expect(service.create).toBeTruthy();
expect(service.updateAll).toBeTruthy();
expect(service.updateAttributes).toBeTruthy();
expect(service.find).toBeTruthy();
expect(service.findById).toBeTruthy();
expect(service.findOne).toBeTruthy();
})
);
let room: RoomInterface = new Room();
room.name = Date.now().toString();
it('should create a new room instance',
injectAsync([RoomApi], (roomApi: RoomApi) => {
return roomApi.create(room)
.subscribe((room: RoomInterface) => expect(room.id).toBeTruthy());
})
);
it('should find room instance',
injectAsync([RoomApi], (roomApi: RoomApi) => {
return roomApi.findOne({ where: room })
.subscribe((room: RoomInterface) => expect(room.id).toBeTruthy());
})
);
});
开发者ID:Jeff-Lewis,项目名称:loopback-sdk-builder,代码行数:33,代码来源:room-service.service.spec.ts
示例2: describe
describe(selector, () => {
it('should instantiate component without fail', injectAsync([], () => {
return setup()
.then(() => promiseWait());
}));
it('should destroy component without fail', injectAsync([], () => {
return setup()
.then((api: ComponentFixture<any>) => api.destroy())
.then(() => promiseWait());
}));
});
开发者ID:robwafle,项目名称:ng2-material,代码行数:11,代码来源:util.ts
示例3: describe
describe('hide', () => {
it('should hide sidenav by name', injectAsync([], () => {
return setup()
.then(() => service.hide('test'));
}));
it('should reject with invalid sidenav name', injectAsync([], () => {
return setup()
.then(() => service.hide('fake'))
.catch(() => Promise.resolve());
}));
});
开发者ID:robwafle,项目名称:ng2-material,代码行数:11,代码来源:sidenav_service_spec.ts
示例4: describe
describe('md-sidenav-container', () => {
let template = `
<md-sidenav-container>
<md-sidenav name="menu"></md-sidenav>
<md-sidenav name="right" align="right"></md-sidenav>
</md-sidenav-container>`;
it('should be created and destroyed', injectAsync([], () => {
return setup(template).then((api: ITestFixture) => {
api.fixture.destroy();
});
}));
it('should maintain a query list of its children', injectAsync([], () => {
return setup(template).then((api: ITestFixture) => {
expect(api.container.children.length).toBe(2);
api.fixture.destroy();
});
}));
it('should hide any open children when the backdrop is hidden', injectAsync([], () => {
return setup(template).then((api: ITestFixture) => {
let menu: MdSidenav = service.find('menu');
return menu.show().then(() => {
return new Promise((resolve) => {
expect(menu.visible).toBe(true);
let sub = menu.onHidden.subscribe(() => {
expect(menu.visible).toBe(false);
sub.unsubscribe();
resolve();
});
menu.backdropRef.onClick();
});
})
.then(() => promiseWait())
.then(() => api.fixture.destroy());
});
}));
it('should set isPushed if any child elements are side style', injectAsync([], () => {
return setup(template).then((api: ITestFixture) => {
expect(api.container.isPushed).toBe(false);
let menu: MdSidenav = service.find('menu');
menu.style = SidenavStyle.SIDE;
return menu.show()
.then(() => {
expect(api.container.isPushed).toBe(true);
})
.then(() => promiseWait())
.then(() => api.fixture.destroy());
});
}));
});
开发者ID:robwafle,项目名称:ng2-material,代码行数:49,代码来源:sidenav_spec.ts
示例5: describe
describe('TitleFormComponent', () => {
it('should emit submit event with specified title value',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.createAsync(TitleFormComponent)
.then((fixture) => {
// const uut: TitleFormComponent = fixture.componentInstance;
// const el: HTMLElement = fixture.nativeElement;
// spyOn(uut.onSubmit, 'emit');
// const input = <HTMLInputElement> el.querySelector('input');
// const btn = <HTMLButtonElement> el.querySelector('button');
// input.value = 'foo';
// uut['title'] = 'foo';
// btn.click();
// fixture.detectChanges();
// expect(uut.onSubmit.emit).toHaveBeenCalled();
});
}));
});
开发者ID:levinmr,项目名称:angular2-webpack-redux,代码行数:25,代码来源:title-form.component.spec.ts
示例6: describe
describe('LoginService', () => {
let testResponse =
{
success: true,
message: "logged in"
};
beforeEachProviders(() => {
return [
HTTP_PROVIDERS,
provide(XHRBackend, { useClass: MockBackend }),
LoginService
];
});
it('should login', inject([XHRBackend, LoginService], (mockBackend, service) => {
mockBackend.connections.subscribe(
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: testResponse
}
)));
});
let req = {};
req.username = "test";
req.password = "test";
service.login(req).subscribe((res: ServiceResponse) => {
expect(res.success).toBe(true);
expect(res.message).toBe("logged in");
});
}));
it('should should login async', injectAsync([XHRBackend, LoginService], (mockBackend, service) => {
return new Promise((pass, fail) => {
mockBackend.connections.subscribe(
(connection: MockConnection) => {
connection.mockRespond(new Response(
new ResponseOptions({
body: testResponse
}
)));
});
service.login().subscribe((res: ServiceResponse) => {
expect(res.success).toBe(true);
expect(res.message).toBe("logged in");
pass();
});
});
}));
});
开发者ID:Ulbora,项目名称:ContriveDM,代码行数:60,代码来源:login.serviceSpec.ts
示例7: describe
describe('MyApp', () => {
beforeEachProviders(() => [
provide(NavParams, {useClass: MockNavParams}),
provide(ViewController, {useClass: MockClass}),
provide(Platform, {useClass: MockClass}),
Book
]);
beforeEach(injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb
.createAsync(EditBookModal)
.then((componentFixture: ComponentFixture<Type>) => {
editBookModalFixture = componentFixture;
editBookModal = componentFixture.componentInstance;
editBookModalFixture.detectChanges();
})
.catch((err) => {
console.error('ERROR - An error has occurred inside a promise! ' + err);
// throw the error out to the console - http://stackoverflow.com/a/30741722
setTimeout(function(): void { throw err; });
});
}));
it('initialises', () => {
expect(editBookModal).not.toBeNull();
expect(editBookModalFixture).not.toBeNull();
});
});
开发者ID:skray,项目名称:bookmarks,代码行数:29,代码来源:edit-book.spec.ts
示例8: describe
describe('Page2', () => {
beforeEachProviders(() => [
Form,
provide(NavController, {useClass: MockClass}),
provide(NavParams, {useClass: MockClass}),
provide(Config, {useClass: MockClass}),
provide(IonicApp, {useClass: MockClass}),
provide(Platform, {useClass: MockClass}),
]);
beforeEach(injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb
.createAsync(Page2)
.then((componentFixture: ComponentFixture<Page2>) => {
page2Fixture = componentFixture;
page2 = componentFixture.componentInstance;
page2Fixture.detectChanges();
})
.catch(Utils.promiseCatchHandler);
}));
it('initialises', () => {
expect(page2).not.toBeNull();
expect(page2Fixture).not.toBeNull();
});
});
开发者ID:Anhmike,项目名称:clicker,代码行数:27,代码来源:page2.spec.ts
示例9: describe
describe('Directive: MaterializeCollection', () => {
let fixture:ComponentFixture<any>;
beforeEachProviders(() => [TestComponentBuilder]);
beforeEach(injectAsync([TestComponentBuilder], tcb => {
return tcb
.createAsync(Container)
.then((f:ComponentFixture<any>) => {
f.detectChanges();
fixture = f;
});
}));
it('Initialization should be ok', () => {
expect(fixture).toBeDefined();
});
it('Click event should add active class', () => {
let directive:MaterializeCollection = fixture.componentInstance.children.first;
expect(directive).toBeDefined();
$(directive.el.nativeElement).click();
expect($(directive.el.nativeElement).find('li.active').length).toBe(0);
});
});
开发者ID:maxamillion32,项目名称:swagger2-angular2-materialize,代码行数:25,代码来源:materialize-collection.spec.ts
示例10: describe
describe('Component: Modal Content', () => {
let builder: TestComponentBuilder;
beforeEachProviders(() => [RioModalContent]);
beforeEach(inject([TestComponentBuilder],
function (tcb: TestComponentBuilder) {
builder = tcb;
}));
it('should inject the component', inject([RioModalContent],
(component: RioModalContent) => {
expect(component).toBeTruthy();
}));
it('should create the component', injectAsync([], () => {
return builder.createAsync(RioModalContentTestController)
.then((fixture: ComponentFixture<any>) => {
fixture.autoDetectChanges();
let query = fixture.debugElement
.query(By.directive(RioModalContent));
expect(query).toBeTruthy();
expect(query.componentInstance).toBeTruthy();
});
}));
});
开发者ID:NadyaMansurova,项目名称:angular2-redux-starter,代码行数:25,代码来源:modal-content.test.ts
注:本文中的@angular/core/testing.injectAsync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论