Skip to content

Commit

Permalink
fix(columns): Column Grouping should re-render after cols reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding-SE committed Jan 22, 2020
1 parent 507b299 commit bd991f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const gridStub = {
getSortColumns: jest.fn(),
invalidate: jest.fn(),
onColumnsResized: new Slick.Event(),
onColumnsReordered: new Slick.Event(),
onSort: new Slick.Event(),
render: jest.fn(),
setColumns: jest.fn(),
Expand Down Expand Up @@ -184,6 +185,18 @@ describe('GroupingAndColspanService', () => {
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 50);
});

it('should call the "renderPreHeaderRowGroupingTitles" after triggering a grid "onColumnsReordered"', () => {
const spy = jest.spyOn(service, 'renderPreHeaderRowGroupingTitles');

service.init(gridStub, dataViewStub);
gridStub.onColumnsReordered.notify({}, new Slick.EventData(), gridStub);
jest.runAllTimers(); // fast-forward timer

expect(spy).toHaveBeenCalledTimes(2);
expect(setTimeout).toHaveBeenCalledTimes(1);
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 50);
});

it('should call the "renderPreHeaderRowGroupingTitles" after triggering a dataView "onColumnsResized"', () => {
const spy = jest.spyOn(service, 'renderPreHeaderRowGroupingTitles');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class GroupingAndColspanService {
// on all following events, call the
this._eventHandler.subscribe(grid.onSort, () => this.renderPreHeaderRowGroupingTitles());
this._eventHandler.subscribe(grid.onColumnsResized, () => this.renderPreHeaderRowGroupingTitles());
this._eventHandler.subscribe(grid.onColumnsReordered, () => this.renderPreHeaderRowGroupingTitles());
this._eventHandler.subscribe(dataView.onRowCountChanged, () => this.renderPreHeaderRowGroupingTitles());
this.resizerService.onGridAfterResize.subscribe(() => this.renderPreHeaderRowGroupingTitles());

Expand Down

0 comments on commit bd991f0

Please sign in to comment.