Sha256: 6e0bcfc13e448d84f2a817e60bf4c34bee2e4bb11181b8fab6e18e2b9d8616d8

Contents?: true

Size: 1.99 KB

Versions: 46

Compression:

Stored size: 1.99 KB

Contents

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

describe('mapDataUsingRowHeightIndex', () => {
  context('no data spans multiple rows', () => {
    it('maps data to a single cell', () => {
      const config = {
        columns: {
          0: {
            width: 2
          }
        }
      };

      const rowSpanIndex = [
        1
      ];

      const data = [
        [
          'aa'
        ]
      ];

      const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);

      expect(mappedData).to.deep.equal([
        [
          'aa'
        ]
      ]);
    });
  });

  context('single cell spans multiple rows', () => {
    it('maps data to multiple rows', () => {
      const config = {
        columns: {
          0: {
            width: 2
          }
        }
      };

      const rowSpanIndex = [
        5
      ];

      const data = [
        [
          'aabbccddee'
        ]
      ];

      const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);

      expect(mappedData).to.deep.equal([
        ['aa'],
        ['bb'],
        ['cc'],
        ['dd'],
        ['ee']
      ]);
    });
  });

  context('multiple cells spans multiple rows', () => {
    it('maps data to multiple rows', () => {
      const config = {
        columns: {
          0: {
            width: 2
          },
          1: {
            width: 4
          }
        }
      };

      const rowSpanIndex = [
        5
      ];

      const data = [
        [
          'aabbccddee',
          '00001111'
        ]
      ];

      const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);

      expect(mappedData).to.deep.equal([
        [
          'aa',
          '0000'
        ],
        [
          'bb',
          '1111'
        ],
        [
          'cc',
          ''
        ],
        [
          'dd',
          ''
        ],
        [
          'ee',
          ''
        ]
      ]);
    });
  });
});

Version data entries

46 entries across 46 versions & 3 rubygems

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