Prevent some undefined js errors

This commit is contained in:
Juan Cruz Viotti 2014-11-24 13:27:15 -04:00
parent 12fc2e3bfb
commit 1165113240
2 changed files with 10 additions and 0 deletions

View File

@ -4,11 +4,13 @@ tableHelpers = require('./table-helpers')
# TODO: Maybe there is a (sane) way to test this, given
# that the result is not automatically printed by cliff?
exports.horizontal = (contents, map, ordering, colours) ->
return if not contents?
contents = tableHelpers.processTableContents(contents, map)
ordering = tableHelpers.normaliseOrdering(ordering, contents)
return cliff.stringifyObjectRows(contents, ordering, colours)
exports.vertical = (contents, map, ordering) ->
return if not contents?
contents = tableHelpers.processTableContents(contents, map)
ordering = tableHelpers.normaliseOrdering(ordering, contents)

View File

@ -32,3 +32,11 @@ describe 'Table:', ->
for line in expected
expect(result.indexOf(line)).to.not.equal(-1)
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