本文整理匯總了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);
})