TypeScript @angular-core-src-debug-debug_node.DebugElement类(方法)实例源码

下面列出了TypeScript @angular-core-src-debug-debug_node.DebugElement 类(方法)源码代码实例,从而了解它的用法。

作者: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);
            })


问题


面经


文章

微信
公众号

扫码关注公众号