| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 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);
- });
- });
- });
|