scroll.spec.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. const id = 'testContainer';
  2. describe('Scrolling', () => {
  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 load cells below the viewport on scroll down (dimensions of the table was set)', async() => {
  13. const hot = handsontable({
  14. width: 400,
  15. height: 400,
  16. data: Handsontable.helper.createSpreadsheetObjectData(100, 15)
  17. });
  18. const mainHolder = hot.view.wt.wtTable.holder;
  19. const $htCore = $(getHtCore());
  20. let TRs = $htCore.find('tr');
  21. let lastTR = [...TRs.toArray()].pop();
  22. const lastTRTextAtStart = $(lastTR).text();
  23. $(mainHolder).scrollTop(400);
  24. await sleep(300);
  25. TRs = $htCore.find('tr');
  26. lastTR = [...TRs.toArray()].pop();
  27. const lastTRTextLater = $(lastTR).text();
  28. expect(lastTRTextLater).not.toEqual(lastTRTextAtStart);
  29. });
  30. it('should load cells below the viewport on scroll down (dimensions of the table was not set)', async() => {
  31. handsontable({
  32. data: Handsontable.helper.createSpreadsheetObjectData(100, 15)
  33. });
  34. const $htCore = $(getHtCore());
  35. let TRs = $htCore.find('tr');
  36. let lastTR = [...TRs.toArray()].pop();
  37. const lastTRTextAtStart = $(lastTR).text();
  38. await sleep(300);
  39. $(window).scrollTop(window.innerHeight);
  40. await sleep(300);
  41. TRs = $htCore.find('tr');
  42. lastTR = [...TRs.toArray()].pop();
  43. const lastTRTextLater = $(lastTR).text();
  44. expect(lastTRTextLater).not.toEqual(lastTRTextAtStart);
  45. });
  46. });