本文整理汇总了TypeScript中@angular/core/src/debug/debug_node.DebugElement类的典型用法代码示例。如果您正苦于以下问题:TypeScript DebugElement类的具体用法?TypeScript DebugElement怎么用?TypeScript DebugElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DebugElement类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getChildrenBySelector
/**
* Gets a child DebugElement by css selector.
*
* The child of DebugElement are other elements that are "known" to
* Angular.
*/
static getChildrenBySelector(parent: DebugElement, selector: string): DebugElement[] {
const results = [];
parent.queryAll(By.css(selector)).forEach((el) => results.push(el));
parent.children.forEach((de) => {
TestHelper.getChildrenBySelector(de, selector).forEach((el) => results.push(el));
});
return results;
}
示例2: it
it('should show', () => {
dialogService.confirm({
header: '',
message: ''
});
fixture.detectChanges();
const confirm = de.query(By.css('p-confirmDialog'));
expect(confirm === null).toBe(false);
});
示例3: fakeAsync
fakeAsync(() => {
spyOn(component, 'onClickConfirm');
dialogService.confirm({
header: '',
message: ''
});
fixture.detectChanges(); // ngIf
tick();
fixture.detectChanges(); // confirmation service make it happen
const buttons = de.queryAll(By.css('p-confirmDialog button'));
buttons[0].nativeElement.click();
expect(component.onClickConfirm).toHaveBeenCalledTimes(1);
buttons[1].nativeElement.click();
expect(component.onClickConfirm).toHaveBeenCalledTimes(2);
})