Skip to content

Commit

Permalink
refactor(table): set default table padding to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed Jul 26, 2020
1 parent 16ae13d commit a6e6aa3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/table/lib/table.ts
Expand Up @@ -28,7 +28,7 @@ export class Table<T extends IRow = IRow> extends Array<T> {
border: false,
maxCellWidth: Infinity,
minCellWidth: 0,
padding: 0,
padding: 1,
chars: border
};
private headerRow?: Row;
Expand Down
33 changes: 26 additions & 7 deletions packages/table/test/table_test.ts
Expand Up @@ -51,13 +51,13 @@ Deno.test( 'simple border table', () => {
.border( true )
.toString(),
`
┌─────┬──────────┐
│cell1cell2cell3│
├─────┼──────────┤
│cell1cell2cell3│
├─────┼──────────┤
│cell1cell2cell3│
└─────┴──────────┘
┌───────┬───────┬───────┐
cell1cell2cell3
├───────┼───────┼───────┤
cell1cell2cell3
├───────┼───────┼───────┤
cell1cell2cell3
└───────┴───────┴───────┘
`.slice( 1 ) );
} );

Expand Down Expand Up @@ -153,20 +153,23 @@ Deno.test( 'simple nested border table', () => {
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString(),
Table.from( [
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString(),
Table.from( [
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString()
], [
Expand All @@ -175,20 +178,23 @@ Deno.test( 'simple nested border table', () => {
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString(),
Table.from( [
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString(),
Table.from( [
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString()
], [
Expand All @@ -197,20 +203,23 @@ Deno.test( 'simple nested border table', () => {
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString(),
Table.from( [
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString(),
Table.from( [
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.border( true )
.toString()
] ] )
Expand Down Expand Up @@ -291,6 +300,7 @@ Deno.test( 'multiline border table', () => {
[ 'cell1', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.', 'cell3' ],
[ 'cell1', 'cell2', 'At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString(),
Expand Down Expand Up @@ -440,6 +450,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString(),
Expand All @@ -448,6 +459,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'cell1', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr.', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString(),
Expand All @@ -456,6 +468,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString()
Expand All @@ -465,6 +478,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'takimata sanctus est Lorem ipsum.', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString(),
Expand All @@ -473,6 +487,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'cell1', 'cell2', 'cell3' ],
[ 'Stet clita kasd gubergren, no sea takimata.', 'cell2', 'cell3' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString(),
Expand All @@ -481,6 +496,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'cell1', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'sanctus est Lorem ipsum dolor sit.' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString()
Expand All @@ -490,6 +506,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'sed diam nonumy eirmod tempor invidunt ut labore.', 'cell2', 'cell3' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString(),
Expand All @@ -498,6 +515,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'cell1', 'cell2', 'accusam et justo duo.' ],
[ 'cell1', 'cell2', 'cell3' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString(),
Expand All @@ -506,6 +524,7 @@ Deno.test( 'nested multiline border table', () => {
[ 'cell1', 'cell2', 'cell3' ],
[ 'Stet clita kasd gubergren, no sea takimata.', 'cell2', 'cell3' ]
] )
.padding( 0 )
.maxCellWidth( 20 )
.border( true )
.toString()
Expand Down

0 comments on commit a6e6aa3

Please sign in to comment.