Skip to content

Commit

Permalink
fix: do not draw new line on the top (borderless) (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
raffis authored and gajus committed Aug 15, 2019
1 parent 35f360d commit 117f902
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/drawBorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ const drawBorder = (columnSizeIndex, parts) => {
* @returns {string}
*/
const drawBorderTop = (columnSizeIndex, parts) => {
return drawBorder(columnSizeIndex, {
const border = drawBorder(columnSizeIndex, {
body: parts.topBody,
join: parts.topJoin,
left: parts.topLeft,
right: parts.topRight
});

if (border === '\n') {
return '';
}

return border;
};

/**
Expand Down
13 changes: 13 additions & 0 deletions test/drawBorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ describe('drawBorderTop', () => {
expect(drawBorderTop([1, 1], parts)).to.equal('╔═╤═╗\n');
expect(drawBorderTop([5, 10], parts)).to.equal('╔═════╤══════════╗\n');
});

it('no leading new line if borderless', () => {
const parts = {
topLeft: '',
topRight: '',
topBody: '',
topJoin: ''
};

expect(drawBorderTop([1], parts)).to.equal('');
expect(drawBorderTop([1, 1], parts)).to.equal('');
expect(drawBorderTop([5, 10], parts)).to.equal('');
});
});

describe('drawBorderJoin', () => {
Expand Down

0 comments on commit 117f902

Please sign in to comment.