ab65e869afc178c0f92c9e49599b9b31c32cceb2aeb96acbf3164b2729644eee50f88af3cdc348c34a4b02e306c0f9722c404ff96c0d9a5a1a5790f479ee40 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. describe('Core_count', () => {
  2. var id = 'testContainer';
  3. beforeEach(function() {
  4. this.$container = $(`<div id="${id}"></div>`).appendTo('body');
  5. });
  6. afterEach(function() {
  7. destroy();
  8. this.$container.remove();
  9. });
  10. describe('countVisibleRows', () => {
  11. it('should return number of visible rows', () => {
  12. var instance = handsontable({
  13. data: Handsontable.helper.createSpreadsheetData(10, 10),
  14. height: 100,
  15. width: 600
  16. });
  17. expect(instance.countVisibleRows()).toEqual(4);
  18. });
  19. it('should return -1 if table is not rendered', function() {
  20. this.$container.remove();
  21. var instance = handsontable({
  22. data: Handsontable.helper.createSpreadsheetData(10, 10),
  23. width: 100
  24. });
  25. expect(instance.countVisibleRows()).toEqual(-1);
  26. });
  27. });
  28. describe('countRenderedRows', () => {
  29. it('should return number of rendered rows', () => {
  30. var instance = handsontable({
  31. data: Handsontable.helper.createSpreadsheetData(10, 10),
  32. height: 100,
  33. viewportRowRenderingOffset: 0
  34. });
  35. expect(instance.countRenderedRows()).toEqual(5);
  36. });
  37. it('should return number of rendered rows, including rows rendered becausee of viewportRowRenderingOffset', () => {
  38. var instance = handsontable({
  39. data: Handsontable.helper.createSpreadsheetData(50, 10),
  40. height: 100,
  41. viewportRowRenderingOffset: 20
  42. });
  43. expect(instance.countRenderedRows()).toEqual(25);
  44. });
  45. it('should return -1 if table is not rendered', function() {
  46. this.$container.remove();
  47. var instance = handsontable({
  48. data: Handsontable.helper.createSpreadsheetData(10, 10),
  49. width: 100
  50. });
  51. expect(instance.countRenderedRows()).toEqual(-1);
  52. });
  53. });
  54. describe('countVisibleCols', () => {
  55. it('should return number of visible columns', () => {
  56. var instance = handsontable({
  57. data: Handsontable.helper.createSpreadsheetData(10, 10),
  58. width: 100
  59. });
  60. expect(instance.countVisibleCols()).toEqual(10);
  61. });
  62. it('should return -1 if table is not rendered', function() {
  63. this.$container.remove();
  64. var instance = handsontable({
  65. data: Handsontable.helper.createSpreadsheetData(10, 10),
  66. width: 100
  67. });
  68. expect(instance.countVisibleCols()).toEqual(-1);
  69. });
  70. });
  71. });