0
難道你們中的任何一個人都可以幫我解釋如何爲primeng數據表的(onRowSelect)事件編寫單元測試。在我的場景中,我嘗試在用戶單擊行時導航到另一個組件。如何爲primeng數據表編寫jasmine單元測試?
難道你們中的任何一個人都可以幫我解釋如何爲primeng數據表的(onRowSelect)事件編寫單元測試。在我的場景中,我嘗試在用戶單擊行時導航到另一個組件。如何爲primeng數據表編寫jasmine單元測試?
以下是我如何使用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();
});
}));