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();
});
}));