Skip to content

Commit

Permalink
tests: fix failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Feb 15, 2021
1 parent 95b73ba commit c234013
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ const mockDataView = {
beginUpdate: jest.fn(),
endUpdate: jest.fn(),
getItem: jest.fn(),
getItemCount: jest.fn(),
getItems: jest.fn(),
getItemMetadata: jest.fn(),
getLength: jest.fn(),
Expand Down Expand Up @@ -1670,18 +1671,20 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', ()
});

it('should have custom footer with metrics when the DataView "onRowsOrCountChanged" event is triggered', () => {
const mockData = [{ firstName: 'John', lastName: 'Doe' }, { firstName: 'Jane', lastName: 'Smith' }];
const invalidateSpy = jest.spyOn(mockGrid, 'invalidate');
const expectation = {
startTime: expect.toBeDate(),
endTime: expect.toBeDate(),
itemCount: 0,
totalItemCount: 0
itemCount: 2,
totalItemCount: 2
};
jest.spyOn(mockDataView, 'getItemCount').mockReturnValue(mockData.length);

component.gridOptions = { enablePagination: false, showCustomFooter: true };
component.initialization(divContainer, slickEventHandler);
const footerSpy = jest.spyOn(component.slickFooter, 'metrics', 'set');
mockDataView.onRowsOrCountChanged.notify({ currentRowCount: 0, dataView: mockDataView, itemCount: 0, previousRowCount: 1, rowCountChanged: false, rowsChanged: false, rowsDiff: [0] });
mockDataView.onRowsOrCountChanged.notify({ currentRowCount: 2, dataView: mockDataView, itemCount: 2, previousRowCount: 1, rowCountChanged: false, rowsChanged: false, rowsDiff: [2] });

expect(invalidateSpy).toHaveBeenCalled();
expect(component.metrics).toEqual(expectation);
Expand Down

0 comments on commit c234013

Please sign in to comment.