cli-table2
cli-table2 copied to clipboard
Colors in word-wrapped table bleed when closing ANSI sequence wrapped in newlines
This is an edge case, but it managed to trip me up. Failing test:
it('wordWrap with colored text should not bleed',function(){
var table = new Table({style:{border:[],head:[]},wordWrap:true,colWidths:[8]});
table.push([colors.blue('Hello how are you?\n') + '\nthis should be white']);
var expected = [
'┌────────┐'
, '│ ' + colors.blue('Hello') + ' │'
, '│ ' + colors.blue('how') + ' │'
, '│ ' + colors.blue('are') + ' │'
, '│ ' + colors.blue('you?') + ' │'
, '│ ' + 'this' + ' │'
, '│ ' + 'should' + ' │'
, '│ ' + 'be' + ' │'
, '│ ' + 'white' + ' │'
, '└────────┘'
];
expect(table.toString()).to.equal(expected.join('\n'));
});