32692f0cb760cb34242180319a5f6ecd0b00a7fca97c613df3cb2ea8882da5629ba3485b504a8a12b768462cb2f81197da54a0dc9cf21d3b4ae12b3e69bc26 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. describe('preventOverflow option', function () {
  2. var $table,
  3. $container,
  4. $wrapper,
  5. debug = false;
  6. beforeEach(function () {
  7. $wrapper = $('<div></div>').css({ position: 'relative' });
  8. $wrapper.width(500).height(201);
  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(100, 100);
  15. });
  16. afterEach(function () {
  17. if (!debug) {
  18. $('.wtHolder').remove();
  19. }
  20. $wrapper.remove();
  21. });
  22. it('should set overflow to `auto` for master table when `horizontal` value is passed', function () {
  23. var wt = new Walkontable.Core({
  24. table: $table[0],
  25. data: getData,
  26. totalRows: getTotalRows,
  27. totalColumns: getTotalColumns,
  28. preventOverflow: function preventOverflow() {
  29. return 'horizontal';
  30. }
  31. });
  32. wt.draw();
  33. expect($table.parents('.wtHolder').css('overflow')).toBe('auto');
  34. expect($table.parents('.ht_master').css('overflow')).toBe('visible');
  35. });
  36. it('should set overflow-x to `auto` for top clone when `horizontal` value is passed', function () {
  37. var wt = new Walkontable.Core({
  38. table: $table[0],
  39. data: getData,
  40. totalRows: getTotalRows,
  41. totalColumns: getTotalColumns,
  42. columnHeaders: [function (column, TH) {
  43. TH.innerHTML = column + 1;
  44. }],
  45. preventOverflow: function preventOverflow() {
  46. return 'horizontal';
  47. }
  48. });
  49. wt.draw();
  50. expect($(wt.wtTable.wtRootElement.parentNode).find('.ht_clone_top .wtHolder').css('overflow-x')).toBe('auto');
  51. expect($(wt.wtTable.wtRootElement.parentNode).find('.ht_clone_top .wtHolder').css('overflow-y')).toBe('hidden');
  52. });
  53. });