I am trying to test a method that I call upon button click, which is basically an excel download functionality given by ag grid api itself. My test coverage shows like these lines are not covered. Any idea like how to write a test case for this code ? I could not find anything related also. Please help, thank you.
import {GridProperties} from "../grid/gridProperties";
const [agGridProperties, setAgGridProperties] = useState<GridProperties | undefined>();
const triggerExceldownload = () => {
if (!agGridProperties)
return;
setAgGridProperties(agGridProperties);
agGridProperties.api.exportDataAsExcel();
}
js file -
<div>
<Button color="primary" outline onClick={triggerExceldownload} data-testid='id-excel'>
Export
Grid-properties.js
import {ColumnApi, GridApi} from "ag-grid-community";
export interface GridProperties {
api: GridApi;
columnApi: ColumnApi;
}