Blame view
node_modules/table/test/validateTableData.js
1.65 KB
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
/* 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.'); }); }); }); |