Return unknown if no matches in device.getDisplayName()

This commit is contained in:
Juan Cruz Viotti 2014-11-19 08:50:11 -04:00
parent f0e1effc05
commit d77e671648
2 changed files with 13 additions and 4 deletions

View File

@ -5,4 +5,4 @@ exports.getDisplayName = (device) ->
for key, value of DEVICE_NAMES
if _.indexOf(value, device) isnt -1
return key
return 'Unknown'

View File

@ -6,8 +6,6 @@ describe 'Device:', ->
describe '#getDisplayName()', ->
it 'should return Raspberry Pi for that device', ->
displayName = 'Raspberry Pi'
possibleNames = [
'raspberry-pi'
'raspberrypi'
@ -15,4 +13,15 @@ describe 'Device:', ->
]
for name in possibleNames
expect(device.getDisplayName(name)).to.equal(displayName)
expect(device.getDisplayName(name)).to.equal('Raspberry Pi')
it 'should return unknown if no matches', ->
unknownNames = [
'hello'
'foobar'
{}
123
]
for name in unknownNames
expect(device.getDisplayName(name)).to.equal('Unknown')