octoblu-device-schema-transmogrifier
Version:
Transmogrifies message and device schemas from version NULL to v1.0.0 for meshblu devices
53 lines (40 loc) • 1.71 kB
text/coffeescript
{beforeEach, describe, it} = global
{expect} = require 'chai'
_ = require 'lodash'
OctobluDeviceSchemaTransmogrifier = require '../'
describe 'vNull', ->
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'
it 'should not set the configure schema', ->
expect(.schemas.configure).to.be.empty
it 'should not set the message schema', ->
expect(.schemas.message).to.be.empty
it 'should not set the form schema', ->
expect(.schemas.form).to.be.empty
describe "when trying to transmogrify a device that doesn't exist", ->
beforeEach ->
try
new OctobluDeviceSchemaTransmogrifier()
catch error
= error
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 _.cloneDeep()
= .transmogrify()
it 'should do nothing', ->
expect().to.deep.equal