8344c4efa1e7d6fc070a06dcdf2e63e5bde9db4f544fac1aa91e5b66f86b58348097a789fde67c59993f8d2a1aaaf76d7a5488beea6e2be2c6ced5f1f36d09 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. describe('Core_destroyEditor', () => {
  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('editor should not be visible', () => {
  13. handsontable();
  14. selectCell(1, 1);
  15. keyDownUp('enter');
  16. destroyEditor();
  17. expect(isEditorVisible()).toEqual(false);
  18. });
  19. it('value should be saved', () => {
  20. handsontable();
  21. selectCell(1, 1);
  22. keyDownUp('enter');
  23. keyProxy().val('Ted');
  24. destroyEditor();
  25. expect(getDataAtCell(1, 1)).toEqual('Ted');
  26. });
  27. it('cell should be selected', () => {
  28. handsontable();
  29. selectCell(1, 1);
  30. keyDownUp('enter');
  31. destroyEditor();
  32. expect(getSelected()).toEqual([1, 1, 1, 1]);
  33. });
  34. it('should revert original value when param set to true', () => {
  35. handsontable();
  36. selectCell(1, 1);
  37. keyDownUp('enter');
  38. keyProxy().val('Ted');
  39. destroyEditor(true);
  40. expect(getDataAtCell(1, 1)).toEqual(null);
  41. });
  42. it('should not destroy editor on scroll', function() {
  43. this.$container.css({
  44. width: 200,
  45. height: 100
  46. });
  47. handsontable({
  48. data: Handsontable.helper.createSpreadsheetData(20, 10)
  49. });
  50. selectCell(0, 0);
  51. keyDown('enter');
  52. var editor = $('.handsontableInputHolder');
  53. expect(editor.is(':visible')).toBe(true);
  54. this.$container.scroll();
  55. expect(editor.is(':visible')).toBe(true);
  56. });
  57. });