mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 18:56:25 +00:00
Table: Prevent map from being called if contents is undefined
This commit is contained in:
parent
b9d5b0fd59
commit
12fc2e3bfb
@ -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
|
||||
|
@ -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 [
|
||||
|
Loading…
Reference in New Issue
Block a user