作者:borodovisi
项目:Book
/**
* 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;
}
作者:dotCM
项目:core-we
it('should show', () => {
dialogService.confirm({
header: '',
message: ''
});
fixture.detectChanges();
const confirm = de.query(By.css('p-confirmDialog'));
expect(confirm === null).toBe(false);
});
作者:dotCM
项目:core-we
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);
})