本文整理匯總了TypeScript中angular2/testing.ComponentFixture類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ComponentFixture類的具體用法?TypeScript ComponentFixture怎麽用?TypeScript ComponentFixture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ComponentFixture類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: expect
return tcb.createAsync(ngBsTablePaging).then((fixture:ComponentFixture,done)=>{
fixture.componentInstance.pageSize = 100;
fixture.componentInstance.totalRecords = 500;
fixture.componentInstance.currPage = 4;
fixture.detectChanges();
let pgBtnEle = fixture.nativeElement.querySelectorAll('.pagination li');
expect(pgBtnEle.length).toBe(7);
expect(pgBtnEle[4].className).toContain('active');
})
示例2:
return prep.then((fixture: ComponentFixture) => {
fixture.detectChanges();
let debug = fixture.debugElement.query(By.css('md-sidenav'));
return {
fixture: fixture,
component: debug.componentInstance,
debug: debug
};
}).catch(console.error.bind(console));
示例3: expect
return tcb.createAsync(UserListItemComponent).then((fixture: ComponentFixture) => {
fixture.componentInstance.id = '50';
fixture.componentInstance.username = 'barretodavid';
fixture.componentInstance.email = 'barretollano@gmail.com';
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('span.username')).toHaveText('Username: barretodavid');
expect(compiled.querySelector('span.email')).toHaveText('Email: barretollano@gmail.com');
});
示例4: expect
.then((fixture: ComponentFixture) => {
let instance: TestCmp = fixture.componentInstance;
instance.config.itemsPerPage = 1;
instance.config.currentPage = 50;
fixture.detectChanges();
let expected = ['1', '...', '48', '49', '50', '51', '52', '...', '100'];
expect(getPageLinkItems(fixture)).toEqual(expected);
});
示例5: Promise
.then((_) => {
fixture.detectChanges();
return new Promise((resolve) => {
// setTimeout(() => {
expect(_kmq).toContain(['identify', 'testUser']);
resolve();
// });
});
});
示例6: Promise
.then((_) => {
fixture.detectChanges();
return new Promise((resolve) => {
setTimeout(() => {
expect(analytics.identify).toHaveBeenCalledWith('1', { userId: '1', firstName: 'John', lastName: 'Doe' });
resolve();
}, 100);
});
});
示例7: Promise
.then((_) => {
fixture.detectChanges();
return new Promise((resolve) => {
setTimeout(() => {
expect(EventSpy).toHaveBeenCalledWith({ action: 'InitiateSearch', properties: { category: 'Search', eventType: 'click' } });
resolve();
});
});
});