4c304d393a949020845785c24ebc2109ae4dd2698c9f0cc20319ec4d5009b102aed7e9faf6da7935c2daa159d857321d32ad80271b7cacd7e57f57a8ccbaf4 1.8 KB

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