tests added
This commit is contained in:
parent
e857b7baa7
commit
49a6a46052
@ -139,46 +139,47 @@ describe('The Meterbus Library', () => {
|
|||||||
expect((telegram.frame as MeterbusLibFrames.ControlFrame).ciField).to.equal(3)
|
expect((telegram.frame as MeterbusLibFrames.ControlFrame).ciField).to.equal(3)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('The Meterbus Longframe Library', () => {
|
|
||||||
let telegram : MeterbusLib.Telegram
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
telegram = new MeterbusLib.Telegram()
|
|
||||||
telegram.fromHexString(inputOkLongFrame_1phase_electric)
|
|
||||||
telegram.parse()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should find the identNo', () => {
|
|
||||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.identNo)
|
|
||||||
.to.equal(17001300)
|
|
||||||
})
|
|
||||||
it('should find the manufacturer', () => {
|
|
||||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.manufacturer)
|
|
||||||
.to.equal("FIN")
|
|
||||||
})
|
|
||||||
it('should find the version', () => {
|
|
||||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.version)
|
|
||||||
.to.equal(0x24)
|
|
||||||
})
|
|
||||||
it('should find the medium', () => {
|
|
||||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.medium)
|
|
||||||
.to.equal("Electrity")
|
|
||||||
})
|
|
||||||
it('should find the accessNo', () => {
|
|
||||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.accessNo)
|
|
||||||
.to.equal(0xd6)
|
|
||||||
})
|
|
||||||
it('should find the status', () => {
|
|
||||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.status)
|
|
||||||
.to.equal(0)
|
|
||||||
})
|
|
||||||
it('should find the signature', () => {
|
|
||||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.signature)
|
|
||||||
.to.deep.equal([0,0])
|
|
||||||
})
|
|
||||||
it('should prepare itself as JSON', () => {
|
|
||||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).getJSON()).to.equal(json_1phase_electric)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('The Meterbus Longframe Library', () => {
|
||||||
|
let telegram : MeterbusLib.Telegram
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
telegram = new MeterbusLib.Telegram()
|
||||||
|
telegram.fromHexString(inputOkLongFrame_1phase_electric)
|
||||||
|
telegram.parse()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should find the identNo', () => {
|
||||||
|
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.identNo)
|
||||||
|
.to.equal(17001300)
|
||||||
|
})
|
||||||
|
it('should find the manufacturer', () => {
|
||||||
|
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.manufacturer)
|
||||||
|
.to.equal("FIN")
|
||||||
|
})
|
||||||
|
it('should find the version', () => {
|
||||||
|
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.version)
|
||||||
|
.to.equal(0x24)
|
||||||
|
})
|
||||||
|
it('should find the medium', () => {
|
||||||
|
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.medium)
|
||||||
|
.to.equal("Electrity")
|
||||||
|
})
|
||||||
|
it('should find the accessNo', () => {
|
||||||
|
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.accessNo)
|
||||||
|
.to.equal(0xd6)
|
||||||
|
})
|
||||||
|
it('should find the status', () => {
|
||||||
|
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.status)
|
||||||
|
.to.equal(0)
|
||||||
|
})
|
||||||
|
it('should find the signature', () => {
|
||||||
|
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.signature)
|
||||||
|
.to.deep.equal([0,0])
|
||||||
|
})
|
||||||
|
it('should prepare itself as JSON', () => {
|
||||||
|
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).getJSON()).to.equal(json_1phase_electric)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import {MeterbusLibExceptions} from './exceptions'
|
import {MeterbusLibExceptions} from './exceptions'
|
||||||
import {MeterbusLibFrames} from './simpleframes'
|
import {MeterbusLibFrames} from './simpleframes'
|
||||||
import {MeterbusLibLongFrame} from './longframe'
|
import {MeterbusLibLongFrame} from './longframe'
|
||||||
|
import {MeterbusLibUtils} from './utils'
|
||||||
|
|
||||||
|
|
||||||
export namespace MeterbusLib {
|
export namespace MeterbusLib {
|
||||||
|
|
||||||
|
@ -26,3 +26,26 @@ describe('The Meterbus Library Utils', () => {
|
|||||||
expect(MeterbusLibUtils.manufCode([0x2e, 0x19])).to.equal("FIN")
|
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)
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user