本文整理汇总了TypeScript中@angular/compiler/testing.ComponentFixture.destroy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ComponentFixture.destroy方法的具体用法?TypeScript ComponentFixture.destroy怎么用?TypeScript ComponentFixture.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/compiler/testing.ComponentFixture
的用法示例。
在下文中一共展示了ComponentFixture.destroy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should load user list', fakeAsync(() => {
let elementList = null;
let fixture: ComponentFixture<UserListComponent> = null;
spyConnection = jasmine.createSpy('connection');
spyConnection.and.returnValue({
body: {
objects: [
{
id: 'USER_ID_1',
firstName: 'fOO',
lastName: 'bar',
email: 'foo.bar@wishtack.com'
},
{
id: 'USER_ID_2',
firstName: 'john',
lastName: 'woo',
email: 'john.woo@wishtack.com'
}
]
},
status: 200
});
fixture = this.testComponentBuilder
.createFakeAsync(UserListComponent);
fixture.detectChanges();
elementList = fixture.debugElement.queryAll(By.css('wt-user-display'));
expect(elementList.length).toEqual(2);
expect(elementList[0].nativeElement.innerText.trim()).toEqual('Foo BAR foo.bar@wishtack.com');
expect(elementList[1].nativeElement.innerText.trim()).toEqual('John WOO john.woo@wishtack.com');
expect(spyConnection.calls.count()).toEqual(1);
expect(spyConnection).toHaveBeenCalledWith({
body: '',
method: RequestMethod.Get,
url: '/api/v1/users/'
});
/* @hack: Avoiding 'periodic timer(s) still in the queue' error due to rxjs timeout operator. */
tick(5000);
fixture.destroy();
}));
示例2: expect
talk.whenStable().then(() => {
const avatar = talk.nativeElement.querySelector('.talk .talk-speakerAvatar').getAttribute('src');
expect(avatar).toEqual(fakeTalk.speaker.avatar);
talk.destroy();
});
示例3: afterEach
afterEach(() => {
_api.destroy();
});