Sha256: 92ebb6d0ea200258f3682ed6b22fe6a53f88fd46ca6eed46d211abf3c92e5e00

Contents?: true

Size: 1.65 KB

Versions: 46

Compression:

Stored size: 1.65 KB

Contents

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

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

describe('validateTableData', () => {
  context('table does not have a row', () => {
    it('throws an error', () => {
      expect(() => {
        validateTableData([]);
      }).to.throw(Error, 'Table must define at least one row.');
    });
  });

  context('table does not have a column', () => {
    it('throws an error', () => {
      expect(() => {
        validateTableData([[]]);
      }).to.throw(Error, 'Table must define at least one column.');
    });
  });

  context('row data is not an array', () => {
    it('throws an error', () => {
      expect(() => {
        validateTableData({});
      }).to.throw(Error, 'Table data must be an array.');
    });
  });

  context('column data is not an array', () => {
    it('throws an error', () => {
      expect(() => {
        validateTableData([{}]);
      }).to.throw(Error, 'Table row data must be an array.');
    });
  });

  context('cell data contains a control character', () => {
    it('throws an error', () => {
      expect(() => {
        validateTableData([
          [
            [
              String.fromCodePoint(0x01)
            ]
          ]
        ]);
      }).to.throw(Error, 'Table data must not contain control characters.');
    });
  });

  context('rows have inconsistent number of cells', () => {
    it('throws an error', () => {
      expect(() => {
        validateTableData([
                    ['a', 'b', 'c'],
                    ['a', 'b']
        ]);
      }).to.throw(Error, 'Table must have a consistent number of cells.');
    });
  });
});

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
govuk_publishing_components-17.6.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-17.5.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-17.4.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-17.3.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-17.2.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-17.1.1 node_modules/table/test/validateTableData.js
govuk_publishing_components-17.1.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-17.0.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.29.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.28.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.27.1 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.27.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.26.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.25.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.24.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.23.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.22.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.21.0 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.20.1 node_modules/table/test/validateTableData.js
govuk_publishing_components-16.20.0 node_modules/table/test/validateTableData.js