Sha256: bcf887de83c0eb9dbbe4aca35351a3e1d4caaebb4de565edccdb0294a29d088b
Contents?: true
Size: 1.45 KB
Versions: 46
Compression:
Stored size: 1.45 KB
Contents
import { expect } from 'chai'; import chalk from 'chalk'; import calculateMaximumColumnWidthIndex from './../src/calculateMaximumColumnWidthIndex'; describe('calculateMaximumColumnWidthIndex', () => { it('throws an error when attempting to calculate maximum column value index for an empty data set', () => { expect(() => { calculateMaximumColumnWidthIndex([]); }).to.throw(Error, 'Dataset must have at least one row.'); }); it('calculates the maximum column value index', () => { const maximumColumnValueIndex = calculateMaximumColumnWidthIndex([ [ '', 'a', 'b', 'c' ], [ '', 'a', 'bbbbbbbbbb', 'c' ], [ '', '', 'b', 'ccccc' ] ]); expect(maximumColumnValueIndex).to.deep.equal([0, 1, 10, 5]); }); context('cell values contain ANSI codes', () => { it('uses visual width of the string', () => { const maximumColumnValueIndex = calculateMaximumColumnWidthIndex([ [ chalk.red('aaaaa') ] ]); expect(maximumColumnValueIndex[0]).to.equal(5); }); }); context('cell values contain fullwidth characters', () => { it('uses visual width of the string', () => { const maximumColumnValueIndex = calculateMaximumColumnWidthIndex([ [ chalk.red('古') ] ]); expect(maximumColumnValueIndex[0]).to.equal(2); }); }); });
Version data entries
46 entries across 46 versions & 3 rubygems