readOnly.e2e.js 1.1 KB

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