Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ class Cell {
* @returns {String}
*/
drawTop(drawRight) {
// Spanning cells can use top/bottom junctions for internal row separators.
// Do not let those junctions restore a separator that was explicitly hidden.
if (
this.y > 0 &&
this.chars.mid === '' &&
this.chars.leftMid === '' &&
this.chars.midMid === '' &&
this.chars.rightMid === ''
) {
return '';
}
let content = [];
if (this.cells) {
//TODO: cells should always exist - some tests don't fill it in though
Expand Down
23 changes: 23 additions & 0 deletions test/issues/355-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const Table = require('../..');

describe('empty row separators with column spans', () => {
const options = {
chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },
colWidths: [5, 5],
style: { head: [], border: [] },
};

test('does not draw a junction below a spanning cell', () => {
const table = new Table(options);
table.push([{ content: 'wide', colSpan: 2 }], ['one', 'two']);

expect(table.toString()).toEqual(['┌───────────┐', '│ wide │', '│ one │ two │', '└─────┴─────┘'].join('\n'));
});

test('does not draw a junction above a spanning cell', () => {
const table = new Table(options);
table.push(['one', 'two'], [{ content: 'wide', colSpan: 2 }]);

expect(table.toString()).toEqual(['┌─────┬─────┐', '│ one │ two │', '│ wide │', '└───────────┘'].join('\n'));
});
});