6a5c34b0fd64dc86c6e2b9de37a7de7bc53ba1a08249f908a0cf4fc46aba356e367da9a66124add0274961270eccfd5f573152b78726e8caa55e3f21d47e7e 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use strict';
  2. describe('WalkontableScrollbar', function () {
  3. var $table,
  4. $container,
  5. $wrapper,
  6. debug = false;
  7. beforeEach(function () {
  8. $wrapper = $('<div></div>').css({ overflow: 'hidden' });
  9. $container = $('<div></div>');
  10. $table = $('<table></table>'); // create a table that is not attached to document
  11. $wrapper.append($container);
  12. $container.append($table);
  13. $wrapper.appendTo('body');
  14. createDataArray();
  15. });
  16. afterEach(function () {
  17. if (!debug) {
  18. $('.wtHolder').remove();
  19. }
  20. $wrapper.remove();
  21. });
  22. it('should table in DIV.wtHolder that contains 2 scrollbars', function () {
  23. var wt = new Walkontable.Core({
  24. table: $table[0],
  25. data: getData,
  26. totalRows: getTotalRows,
  27. totalColumns: getTotalColumns
  28. });
  29. wt.draw();
  30. expect($table.parents('.wtHolder').length).toEqual(1);
  31. });
  32. it('scrolling should have no effect when totalRows is smaller than height', function () {
  33. this.data.splice(5, this.data.length - 5);
  34. try {
  35. var wt = new Walkontable.Core({
  36. table: $table[0],
  37. data: getData,
  38. totalRows: getTotalRows,
  39. totalColumns: getTotalColumns
  40. });
  41. wt.draw();
  42. wt.wtOverlays.topOverlay.onScroll(1);
  43. expect(wt.getViewport()[0]).toEqual(0);
  44. wt.wtOverlays.topOverlay.onScroll(-1);
  45. expect(wt.getViewport()[0]).toEqual(0);
  46. } catch (e) {
  47. expect(e).toBeUndefined();
  48. }
  49. });
  50. });