Skip to content

Improve the arguments forwarding for global hooks #8668

@budnix

Description

@budnix

Description

The arguments passed in the global hooks are forwarded always in the same count. No matter how many of them were passed on. This creates a mess in the tests where each toHaveBeenCalled-kind matcher has to be filled with the missing arguments (undefined values). It's not convenient.

Some example of that odd creatures:

expect(onAfterValidate).toHaveBeenCalledWith(true, 10, undefined, undefined, undefined, undefined);

or

let hookArguments = new Array(6).fill(void 0);

hookArguments[0] = [[0, 'foo', 'bar', 'foo2']];
hookArguments[1] = 'caller-custom-source';

expect(afterSetSourceDataAtCellSpy).toHaveBeenCalledWith(...hookArguments);

Guilty lines:

  1. https://github.com/handsontable/handsontable/blob/master/src/pluginHooks.js#L2371
  2. https://github.com/handsontable/handsontable/blob/master/src/pluginHooks.js#L2399

Steps to reproduce

Demo

https://jsfiddle.net/handsoncode/8ffpsqt6/

Your environment

  • Handsontable version: any
  • Browser Name and version: -
  • Operating System: -

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions