mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-29 15:44:26 +00:00
Implement device module with getDisplayName()
This commit is contained in:
parent
8c56d1bbf1
commit
f0e1effc05
7
lib/device/device-names.json
Normal file
7
lib/device/device-names.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"Raspberry Pi": [
|
||||||
|
"raspberry-pi",
|
||||||
|
"raspberrypi",
|
||||||
|
"rpi"
|
||||||
|
]
|
||||||
|
}
|
8
lib/device/device.coffee
Normal file
8
lib/device/device.coffee
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
_ = require('lodash')
|
||||||
|
DEVICE_NAMES = require('./device-names.json')
|
||||||
|
|
||||||
|
exports.getDisplayName = (device) ->
|
||||||
|
for key, value of DEVICE_NAMES
|
||||||
|
if _.indexOf(value, device) isnt -1
|
||||||
|
return key
|
||||||
|
|
18
lib/device/device.spec.coffee
Normal file
18
lib/device/device.spec.coffee
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
expect = require('chai').expect
|
||||||
|
device = require('./device')
|
||||||
|
|
||||||
|
describe 'Device:', ->
|
||||||
|
|
||||||
|
describe '#getDisplayName()', ->
|
||||||
|
|
||||||
|
it 'should return Raspberry Pi for that device', ->
|
||||||
|
displayName = 'Raspberry Pi'
|
||||||
|
|
||||||
|
possibleNames = [
|
||||||
|
'raspberry-pi'
|
||||||
|
'raspberrypi'
|
||||||
|
'rpi'
|
||||||
|
]
|
||||||
|
|
||||||
|
for name in possibleNames
|
||||||
|
expect(device.getDisplayName(name)).to.equal(displayName)
|
Loading…
x
Reference in New Issue
Block a user