Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 683b716

Browse files
committed
chore: add missing test coverage
1 parent 26838d9 commit 683b716

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid.component.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ Object.defineProperty(paginationServiceStub, 'totalItems', {
183183
});
184184

185185
const resizerServiceStub = {
186+
isAutoHeightEnabled: true,
187+
autoHeightRecalcRow: 100,
186188
init: jest.fn(),
187189
dispose: jest.fn(),
188190
bindAutoResizeDataGrid: jest.fn(),
@@ -2272,6 +2274,32 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
22722274
expect(footerSpy).toHaveBeenCalledWith(expectation);
22732275
});
22742276

2277+
it('should call a grid resize when the DataView "onRowCountChanged" event is triggered with a low dataset length and autoResize.autoHeight is enabled', () => {
2278+
const mockData = [
2279+
{ firstName: 'John', lastName: 'Doe' },
2280+
{ firstName: 'Jane', lastName: 'Smith' },
2281+
];
2282+
const invalidateSpy = jest.spyOn(mockGrid, 'invalidate');
2283+
const expectation = {
2284+
startTime: expect.any(Date),
2285+
endTime: expect.any(Date),
2286+
itemCount: 2,
2287+
totalItemCount: 2,
2288+
};
2289+
jest.spyOn(mockDataView, 'getItemCount').mockReturnValue(mockData.length);
2290+
jest.spyOn(mockDataView, 'getFilteredItemCount').mockReturnValue(mockData.length);
2291+
jest.spyOn(mockDataView, 'getLength').mockReturnValue(mockData.length);
2292+
const resizerSpy = jest.spyOn(resizerServiceStub, 'resizeGrid');
2293+
2294+
component.gridOptions = { enableAutoResize: true, autoResize: { autoHeight: true } };
2295+
component.initialization(slickEventHandler);
2296+
mockDataView.onRowCountChanged.notify({ current: 2, previous: 0, dataView: mockDataView, itemCount: 0, callingOnRowsChanged: false });
2297+
2298+
expect(invalidateSpy).toHaveBeenCalled();
2299+
expect(component.metrics).toEqual(expectation);
2300+
expect(resizerSpy).toHaveBeenCalled();
2301+
});
2302+
22752303
it('should have custom footer with metrics when the DataView "onSetItemsCalled" event is triggered', () => {
22762304
const expectation = {
22772305
startTime: expect.toBeDate(),

0 commit comments

Comments
 (0)