2017-02-20 8 views

答えて

0

ここでは、onRowClickのユニットテストをPromeNGデータテーブルで行う方法を示します。これは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(); 
    }); 
})); 
関連する問題