2014-11-19 12:45:56 +00:00
|
|
|
expect = require('chai').expect
|
|
|
|
device = require('./device')
|
2014-11-24 12:54:35 +00:00
|
|
|
DEVICES = require('./device-data.json')
|
2014-11-19 12:45:56 +00:00
|
|
|
|
|
|
|
describe 'Device:', ->
|
|
|
|
|
|
|
|
describe '#getDisplayName()', ->
|
|
|
|
|
|
|
|
it 'should return Raspberry Pi for that device', ->
|
|
|
|
possibleNames = [
|
|
|
|
'raspberry-pi'
|
|
|
|
'raspberrypi'
|
|
|
|
'rpi'
|
|
|
|
]
|
|
|
|
|
|
|
|
for name in possibleNames
|
2014-11-19 12:50:11 +00:00
|
|
|
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')
|
2014-11-24 12:25:45 +00:00
|
|
|
|
|
|
|
describe '#getSupportedDevices()', ->
|
|
|
|
|
2014-11-24 12:54:35 +00:00
|
|
|
result = null
|
|
|
|
|
|
|
|
beforeEach ->
|
2014-11-24 12:25:45 +00:00
|
|
|
result = device.getSupportedDevices()
|
2014-11-24 12:54:35 +00:00
|
|
|
|
|
|
|
it 'should return an array', ->
|
2014-11-24 12:25:45 +00:00
|
|
|
expect(result).to.be.an.instanceof(Array)
|
2014-11-24 12:54:35 +00:00
|
|
|
|
|
|
|
it 'should return all slugs', ->
|
|
|
|
for device in DEVICES
|
|
|
|
expect(result.indexOf(device.slug)).to.not.equal(-1)
|