tableClassName.spec.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. describe('settings', () => {
  2. describe('tableClassName', () => {
  3. var id = 'testContainer';
  4. beforeEach(function() {
  5. this.$container = $(`<div id="${id}"></div>`).appendTo('body');
  6. });
  7. afterEach(function() {
  8. if (this.$container) {
  9. destroy();
  10. this.$container.remove();
  11. }
  12. });
  13. it('should add class name every table element inside handsontable wrapper element (as string, without overlays)', () => {
  14. var hot = handsontable({
  15. colHeaders: false,
  16. rowHeaders: false,
  17. tableClassName: 'foo'
  18. });
  19. var possibleCounts = [3, 4]; // 3 for non-pro, 4 for pro (bottom overlay)
  20. // all overlays is created anyway but without left-top corner
  21. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
  22. });
  23. it('should add class name every table element inside handsontable wrapper element (as string, with overlays)', () => {
  24. var hot = handsontable({
  25. colHeaders: true,
  26. rowHeaders: true,
  27. tableClassName: 'foo'
  28. });
  29. var possibleCounts = [4, 5]; // 4 for non-pro, 5 for pro (bottom overlay)
  30. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
  31. });
  32. it('should add class name every table element inside handsontable wrapper element (as string with spaces, without overlays)', () => {
  33. var hot = handsontable({
  34. colHeaders: false,
  35. rowHeaders: false,
  36. tableClassName: 'foo bar'
  37. });
  38. var possibleCounts = [3, 4]; // 3 for non-pro, 4 for pro (bottom overlay)
  39. // all overlays is created anyway but without left-top corner
  40. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
  41. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.bar').length)).toBeGreaterThan(-1);
  42. });
  43. it('should add class name every table element inside handsontable wrapper element (as string with spaces, with overlays)', () => {
  44. var hot = handsontable({
  45. colHeaders: true,
  46. rowHeaders: true,
  47. tableClassName: 'foo bar'
  48. });
  49. var possibleCounts = [4, 5]; // 4 for non-pro, 5 for pro (bottom overlay)
  50. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
  51. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.bar').length)).toBeGreaterThan(-1);
  52. });
  53. it('should add class name every table element inside handsontable wrapper element (as array, without overlays)', () => {
  54. var hot = handsontable({
  55. colHeaders: false,
  56. rowHeaders: false,
  57. tableClassName: ['foo', 'bar', 'baz']
  58. });
  59. var possibleCounts = [3, 4]; // 3 for non-pro, 4 for pro (bottom overlay)
  60. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
  61. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.bar').length)).toBeGreaterThan(-1);
  62. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.baz').length)).toBeGreaterThan(-1);
  63. });
  64. it('should add class name every table element inside handsontable wrapper element (as array, with overlays)', () => {
  65. var hot = handsontable({
  66. colHeaders: true,
  67. rowHeaders: true,
  68. tableClassName: ['foo', 'bar', 'baz']
  69. });
  70. var possibleCounts = [4, 5]; // 4 for non-pro, 5 for pro (bottom overlay)
  71. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
  72. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.bar').length)).toBeGreaterThan(-1);
  73. expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.baz').length)).toBeGreaterThan(-1);
  74. });
  75. });
  76. });