scrollbar.spec.js 1.4 KB

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