2014-11-19 14:20:36 +00:00
|
|
|
expect = require('chai').expect
|
|
|
|
table = require('./table')
|
|
|
|
|
|
|
|
OBJECTS =
|
2014-11-19 16:12:08 +00:00
|
|
|
valid:
|
2014-11-19 18:22:45 +00:00
|
|
|
One: 'one'
|
|
|
|
Two: 'two'
|
|
|
|
Three: 'three'
|
2014-11-19 14:20:36 +00:00
|
|
|
|
|
|
|
describe 'Table:', ->
|
|
|
|
|
2014-11-19 16:12:08 +00:00
|
|
|
describe '#vertical()', ->
|
|
|
|
|
|
|
|
it 'should return a string respecting the ordering', ->
|
2014-11-19 18:22:45 +00:00
|
|
|
ordering = [ 'One', 'Two', 'Three' ]
|
2014-11-19 16:12:08 +00:00
|
|
|
result = table.vertical(OBJECTS.valid, null, ordering).split('\n')
|
|
|
|
expected = [
|
2014-11-19 18:22:45 +00:00
|
|
|
'One: one'
|
|
|
|
'Two: two'
|
|
|
|
'Three: three'
|
2014-11-19 16:12:08 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
expect(result).to.deep.equal(expected)
|
|
|
|
|
|
|
|
it 'should be able to print everything without explicit ordering', ->
|
|
|
|
result = table.vertical(OBJECTS.valid, null).split('\n')
|
|
|
|
expected = [
|
2014-11-19 18:22:45 +00:00
|
|
|
'One: one'
|
|
|
|
'Two: two'
|
|
|
|
'Three: three'
|
2014-11-19 16:12:08 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
for line in expected
|
|
|
|
expect(result.indexOf(line)).to.not.equal(-1)
|
2014-11-24 17:27:15 +00:00
|
|
|
|
|
|
|
it 'should return undefined if contents does not exist', ->
|
|
|
|
expect(table.vertical(undefined)).to.be.undefined
|
|
|
|
|
|
|
|
describe '#horizontal()', ->
|
|
|
|
|
|
|
|
it 'should return undefined if contents does not exist', ->
|
|
|
|
expect(table.horizontal(undefined)).to.be.undefined
|