Sha256: 8615894258e310ee4679fb75248d7d5a406dca95305b9824a61c56a616d4f375

Contents?: true

Size: 1.69 KB

Versions: 46

Compression:

Stored size: 1.69 KB

Contents

/* eslint-disable max-nested-callbacks */

import {
    expect
} from 'chai';
import calculateRowHeightIndex from './../src/calculateRowHeightIndex';

describe('calculateRowHeightIndex', () => {
  context('single column', () => {
    context('cell content width is lesser than column width', () => {
      it('is equal to 1', () => {
        const data = [
          [
            'aaa'
          ]
        ];

        const config = {
          columns: {
            0: {
              width: 10,
              wrapWord: false
            }
          }
        };

        const rowSpanIndex = calculateRowHeightIndex(data, config);

        expect(rowSpanIndex[0]).to.equal(1);
      });
    });
    context('cell content width is twice the size of the column width', () => {
      it('is equal to 2', () => {
        const data = [
          [
            'aaabbb'
          ]
        ];

        const config = {
          columns: {
            0: {
              width: 3,
              wrapWord: false
            }
          }
        };

        const rowSpanIndex = calculateRowHeightIndex(data, config);

        expect(rowSpanIndex[0]).to.equal(2);
      });
    });
  });
  context('multiple columns', () => {
    context('multiple cell content width is greater than the column width', () => {
      it('uses the largest height', () => {
        const data = [
          ['aaabbb'],
          ['aaabbb']
        ];

        const config = {
          columns: {
            0: {
              width: 2,
              wrapWord: false
            }
          }
        };

        const rowSpanIndex = calculateRowHeightIndex(data, config);

        expect(rowSpanIndex[0]).to.equal(3);
      });
    });
  });
});

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.21.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.20.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.19.1 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.19.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.18.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.17.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.16.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.15.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.14.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.13.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.12.2 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.12.1 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.12.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.11.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.10.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.9.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.8.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.7.0 node_modules/table/test/calculateRowHeightIndex.js
govuk_publishing_components-17.6.1 node_modules/table/test/calculateRowHeightIndex.js