2017-02-20 73 views

回答

0

以下是我如何使用PromeNG数据表进行onRowClick单元测试。它应该和onRowSelect非常相似。

你可以看一下成分,并在我的github上回购其单元测试:https://github.com/ipassynk/ristorante-fornello/tree/master/src/app/menu

it('should call showDetails on row click', async(() => { 
    const spy = spyOn(comp, 'showDetails'); 
    fixture.detectChanges(); 

    const cell = debugElement.queryAll(By.css('.ui-datatable-odd .ui-cell-data'))[0]; 
    cell.nativeElement.click(); 
    fixture.detectChanges(); 

    fixture.whenStable().then(() => { 
    expect(spy).toHaveBeenCalled(); 
    }); 
})); 
相关问题