UNPKG

@reactual/handsontable

Version:

Spreadsheet-like data grid editor

82 lines (71 loc) 2.42 kB
describe('Core_count', () => { var id = 'testContainer'; beforeEach(function() { this.$container = $(`<div id="${id}"></div>`).appendTo('body'); }); afterEach(function() { destroy(); this.$container.remove(); }); describe('countVisibleRows', () => { it('should return number of visible rows', () => { var instance = handsontable({ data: Handsontable.helper.createSpreadsheetData(10, 10), height: 100, width: 600 }); expect(instance.countVisibleRows()).toEqual(4); }); it('should return -1 if table is not rendered', function() { this.$container.remove(); var instance = handsontable({ data: Handsontable.helper.createSpreadsheetData(10, 10), width: 100 }); expect(instance.countVisibleRows()).toEqual(-1); }); }); describe('countRenderedRows', () => { it('should return number of rendered rows', () => { var instance = handsontable({ data: Handsontable.helper.createSpreadsheetData(10, 10), height: 100, viewportRowRenderingOffset: 0 }); expect(instance.countRenderedRows()).toEqual(5); }); it('should return number of rendered rows, including rows rendered becausee of viewportRowRenderingOffset', () => { var instance = handsontable({ data: Handsontable.helper.createSpreadsheetData(50, 10), height: 100, viewportRowRenderingOffset: 20 }); expect(instance.countRenderedRows()).toEqual(25); }); it('should return -1 if table is not rendered', function() { this.$container.remove(); var instance = handsontable({ data: Handsontable.helper.createSpreadsheetData(10, 10), width: 100 }); expect(instance.countRenderedRows()).toEqual(-1); }); }); describe('countVisibleCols', () => { it('should return number of visible columns', () => { var instance = handsontable({ data: Handsontable.helper.createSpreadsheetData(10, 10), width: 100 }); expect(instance.countVisibleCols()).toEqual(10); }); it('should return -1 if table is not rendered', function() { this.$container.remove(); var instance = handsontable({ data: Handsontable.helper.createSpreadsheetData(10, 10), width: 100 }); expect(instance.countVisibleCols()).toEqual(-1); }); }); });