Table: Prevent map from being called if contents is undefined

This commit is contained in:
Juan Cruz Viotti 2014-11-24 13:18:35 -04:00
parent b9d5b0fd59
commit 12fc2e3bfb
2 changed files with 8 additions and 0 deletions

View File

@ -58,6 +58,7 @@ exports.prepareObject = (object) ->
return object
exports.processTableContents = (contents, map) ->
return if not contents?
# Allows us to simplify the algorithm by not
# concerning about different input types

View File

@ -1,4 +1,5 @@
expect = require('chai').expect
sinon = require('sinon')
_ = require('lodash')
tableHelpers = require('./table-helpers')
@ -102,6 +103,12 @@ describe 'Table Helpers:', ->
expect(result).to.deep.equal([ Hey: 'yo' ])
it 'should not call map if contents does not exist', ->
map = sinon.spy()
tableHelpers.processTableContents(null, map)
tableHelpers.processTableContents(undefined, map)
expect(map).to.not.have.been.called
it 'should get rid of keys not starting with letters', ->
result = tableHelpers.processTableContents(OBJECTS.basic, _.identity)
expect(result).to.deep.equal [