tests added

This commit is contained in:
Wolfgang Hottgenroth 2017-08-10 16:47:50 +02:00
parent e857b7baa7
commit 49a6a46052
3 changed files with 70 additions and 44 deletions

View File

@ -139,6 +139,9 @@ describe('The Meterbus Library', () => {
expect((telegram.frame as MeterbusLibFrames.ControlFrame).ciField).to.equal(3)
})
})
describe('The Meterbus Longframe Library', () => {
let telegram : MeterbusLib.Telegram
@ -180,5 +183,3 @@ describe('The Meterbus Library', () => {
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).getJSON()).to.equal(json_1phase_electric)
})
})
})

View File

@ -1,6 +1,8 @@
import {MeterbusLibExceptions} from './exceptions'
import {MeterbusLibFrames} from './simpleframes'
import {MeterbusLibLongFrame} from './longframe'
import {MeterbusLibUtils} from './utils'
export namespace MeterbusLib {

View File

@ -26,3 +26,26 @@ describe('The Meterbus Library Utils', () => {
expect(MeterbusLibUtils.manufCode([0x2e, 0x19])).to.equal("FIN")
})
})
describe('The jsonPrepare function in the Meterbus Library Utils', () => {
it('should forward regular properties of an object', () => {
let objIn = {'a': 1, 'b':2}
let objOut = objIn
expect(MeterbusLibUtils.jsonPrepaper(objIn, [])).to.deep.equal(objOut)
})
it('should hide properties in the hide list', () => {
let objIn = {'a': 1, 'b':2}
let objOut = {'a': 1}
expect(MeterbusLibUtils.jsonPrepaper(objIn, ['b'])).to.deep.equal(objOut)
})
it('should hide properties beginning with two underscores', () => {
let objIn = {'a': 1, '__b':2}
let objOut = {'a': 1}
expect(MeterbusLibUtils.jsonPrepaper(objIn, [])).to.deep.equal(objOut)
})
it('should remove one leading underscore from property names', () => {
let objIn = {'_a': 1, 'b':2}
let objOut = {'a': 1, 'b':2}
expect(MeterbusLibUtils.jsonPrepaper(objIn, [])).to.deep.equal(objOut)
})
})