octoblu-device-schema-transmogrifier
Version:
Transmogrifies message and device schemas from version NULL to v1.0.0 for meshblu devices
40 lines (31 loc) • 1.21 kB
text/coffeescript
_ = require 'lodash'
OctobluDeviceSchemaTransmogrifier = require '../'
describe 'a device with data', ->
beforeEach ->
=
other: true
= new OctobluDeviceSchemaTransmogrifier
= .transmogrify()
it 'should preserve existing data', ->
expect(.other).to.be.true
it 'should set the version to 1.0.0', ->
expect(.schemas.version).to.equal '1.0.0'
describe "when trying to transmogrify a device that doesn't exist", ->
beforeEach ->
try
new OctobluDeviceSchemaTransmogrifier()
catch e
= e
it "should throw an exception telling us how bad the core dispatcher is for giving us no data.", ->
expect().to.exist
expect(.message).to.equal "Someone tried to transmogrify an undefined device! Stop doing that."
describe 'migrating a v1 schema', ->
beforeEach ->
=
optionsSchema: {whatever: true}
schemas:
version: '1.0.0'
= new OctobluDeviceSchemaTransmogrifier
= .transmogrify()
it 'should do nothing', ->
expect().to.deep.equal