I am having a function like below in my component file like below
onGridReady(params) {
this.gridApi = params.api;
this.columnApi = params.columnApi;
this.gridApi.setDomLayout('autoHeight');
this.gridApi.sizeColumnsToFit();
params.api.setRowData(this.deviceConfigurations);
}
For the above function I am writing the spec like the below one
describe('#onGridReady()', () => {
const params = {
api: new MockGridApi(),
ColumnApi: new MockColumnApi(),
};
it('call the function', () => {
spyOn(component, 'onGridReady').and.callThrough();
component.onGridReady(params);
expect(component.onGridReady).toHaveBeenCalled();
});
});
The spec passes as well as the coverage is done for the above function. But I would like to know whether is it the correct way or writing the spec or do I need to write more specs like to sizeColumnsToFit()
has been called etc.,
Could anyone can give your view about it.