I am trying to unit test a function that includes calls to the gridApi, like this.gridApi.getSelectedRows();
. When the unit test gets to this line, it gives this error: Failed: Cannot read property 'getSelectedRows' of undefined
, because gridApi hasn't been defined yet.
How can I define the gridApi from a unit test? It is normally defined in the onGridReady function like this:
onGridReady(params) {
this.gridApi = params.api;
this.gridColumnApi = params.columnApi;
this.gridApi.sizeColumnsToFit();
}
Is it possible to trigger onGridReady
from a unit test? I don't know what params could be sent to it. Is there some other way to define this.gridApi
instead?