3655b086663aa894cdefb889e6a714d8db69b7646a52c93d3f47e531db2b979eabf81efcb6b92b27683da3650325a4b59d1c0b213d57f861461d03662393cd 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. describe('ContextMenuReadOnly', () => {
  2. var id = 'testContainer';
  3. beforeEach(function() {
  4. this.$container = $(`<div id="${id}"></div>`).appendTo('body');
  5. });
  6. afterEach(function() {
  7. if (this.$container) {
  8. destroy();
  9. this.$container.remove();
  10. }
  11. });
  12. it('should trigger `afterSetCellMeta` callback after changing cell to read only by context menu', () => {
  13. var afterSetCellMetaCallback = jasmine.createSpy('afterSetCellMetaCallback');
  14. var rows = 5,
  15. columns = 5;
  16. handsontable({
  17. data: Handsontable.helper.createSpreadsheetData(rows, columns),
  18. rowHeaders: true,
  19. colHeaders: true,
  20. contextMenu: true,
  21. afterSetCellMeta: afterSetCellMetaCallback
  22. });
  23. selectCell(2, 3);
  24. contextMenu();
  25. var changeToReadOnluButton = $('.htItemWrapper').filter(function() {
  26. return $(this).text() === 'Read only';
  27. })[0];
  28. $(changeToReadOnluButton).simulate('mousedown');
  29. expect(afterSetCellMetaCallback).toHaveBeenCalledWith(2, 3, 'readOnly', true, undefined, undefined);
  30. });
  31. });