【发布时间】:2020-04-06 20:30:06
【问题描述】:
我正在尝试测试 ag-grid 功能但无法触发事件。
it('should open Component on double click', () => {
component.gridOptions.api.setRowData(ordersStub);
fixture.detectChanges();
const node = component.gridOptions.api.getRowNode(ordersStub[0].id);
const nodeData = node.data;
const element = (fixture.debugElement.nativeElement as HTMLElement).querySelector(`[row-id="${nodeData.id}"]`);
const onRowDoubleClickedSpy = spyOn(component, 'onRowDoubleClicked');
element.dispatchEvent(new MouseEvent('dblclick', { bubbles: true, view: window, cancelable: true }));
expect(onRowDoubleClickedSpy).toHaveBeenCalled();
});
我做错了什么?
【问题讨论】: