Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
Merge 780ef66 into 00b528d
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantcornholio committed Dec 18, 2018
2 parents 00b528d + 780ef66 commit 41d12fa
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
14 changes: 14 additions & 0 deletions advanced-usage.md
Expand Up @@ -17,6 +17,20 @@

```

##### colSpan works with headers too:
┌───────────┬────────┐
│ foobar │ bazbar │
├─────┬─────┼────────┤
│ foo │ bar │ baz │
└─────┴─────┴────────┘
```javascript
var table = new Table({
style: {border:[], head: []},
head:[{content: 'foobar', colSpan: 2}, {content: 'bazbar'}]
});

table.push(['foo', 'bar', 'baz']);
```

##### use colSpan to span columns - (colSpan below normal cell)
┌───────┬───────┐
Expand Down
58 changes: 58 additions & 0 deletions test/table-test.js
Expand Up @@ -69,6 +69,64 @@ describe('@api Table ',function(){

expect(table.toString()).to.equal(expected.join("\n"));
});

it('will render head with text', function() {
var table = new Table({
style: {border:[], head: []},
head:['foobar', 'barbar', 'bazbar'],
});

table.push(['foo', 'bar', 'baz']);

var expected = [
'┌────────┬────────┬────────┐'
,'│ foobar │ barbar │ bazbar │'
,'├────────┼────────┼────────┤'
,'│ foo │ bar │ baz │'
,'└────────┴────────┴────────┘'
];

expect(table.toString()).to.equal(expected.join('\n'));
});

it('will render head with Cells', function() {
var table = new Table({
style: {border:[], head: []},
head:[{content: 'foobar'}, {content: 'barbar'}, {content: 'bazbar'}],
});

table.push(['foo', 'bar', 'baz']);

var expected = [
'┌────────┬────────┬────────┐'
,'│ foobar │ barbar │ bazbar │'
,'├────────┼────────┼────────┤'
,'│ foo │ bar │ baz │'
,'└────────┴────────┴────────┘'
];

expect(table.toString()).to.equal(expected.join('\n'));
});

it('will render colSpan in head correctly', function() {
var table = new Table({
style: {border:[], head: []},
head:[{content: 'foobar', colSpan: 2}, {content: 'bazbar'}],
});

table.push(['foo', 'bar', 'baz']);


var expected = [
'┌───────────┬────────┐'
,'│ foobar │ bazbar │'
,'├─────┬─────┼────────┤'
,'│ foo │ bar │ baz │'
,'└─────┴─────┴────────┘'
];

expect(table.toString()).to.equal(expected.join('\n'));
});
});


Expand Down

0 comments on commit 41d12fa

Please sign in to comment.