utils test adapted to Uint8Array
This commit is contained in:
parent
098633af13
commit
83143ca8c2
@ -17,6 +17,10 @@ export namespace MeterbusLibLongFrame {
|
||||
this._fixedDataHeader = new FixedDataHeader(this._telegram.slice(7, 19))
|
||||
this._fixedDataHeader.parse()
|
||||
}
|
||||
|
||||
getJSON() : string {
|
||||
return JSON.stringify(this)
|
||||
}
|
||||
}
|
||||
|
||||
export class FixedDataHeader {
|
||||
|
@ -179,6 +179,9 @@ describe('The Meterbus Library', () => {
|
||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.signature)
|
||||
.to.deep.equal(new Uint8Array([0,0]))
|
||||
})
|
||||
it('should print itself as json', () => {
|
||||
console.log((telegram.frame as MeterbusLibLongFrame.LongFrame).getJSON())
|
||||
})
|
||||
})
|
||||
|
||||
})
|
@ -8,21 +8,21 @@ const expect = chai.expect
|
||||
|
||||
describe('The Meterbus Library Utils', () => {
|
||||
it('should convert a bcd to a number (10203)', () => {
|
||||
expect(MeterbusLibUtils.bcd([1, 2, 3])).to.equal(10203)
|
||||
expect(MeterbusLibUtils.bcd(new Uint8Array([1, 2, 3]))).to.equal(10203)
|
||||
})
|
||||
it('should convert a bcd to a number (0010203)', () => {
|
||||
expect(MeterbusLibUtils.bcd([0, 1, 2, 3])).to.equal(10203)
|
||||
expect(MeterbusLibUtils.bcd(new Uint8Array([0, 1, 2, 3]))).to.equal(10203)
|
||||
})
|
||||
it('should convert a bcd to a number (0)', () => {
|
||||
expect(MeterbusLibUtils.bcd([0, 0, 0])).to.equal(0)
|
||||
expect(MeterbusLibUtils.bcd(new Uint8Array([0, 0, 0]))).to.equal(0)
|
||||
})
|
||||
it('should convert a bcd to a number (0)', () => {
|
||||
expect(MeterbusLibUtils.bcd([0, 0, 0, 0])).to.equal(0)
|
||||
expect(MeterbusLibUtils.bcd(new Uint8Array([0, 0, 0, 0]))).to.equal(0)
|
||||
})
|
||||
it('should convert a bcd to a number (99999999)', () => {
|
||||
expect(MeterbusLibUtils.bcd([0x99, 0x99, 0x99, 0x99])).to.equal(99999999)
|
||||
expect(MeterbusLibUtils.bcd(new Uint8Array([0x99, 0x99, 0x99, 0x99]))).to.equal(99999999)
|
||||
})
|
||||
it('should convert two number to manufacturer code', () => {
|
||||
expect(MeterbusLibUtils.manufCode([0x2e, 0x19])).to.equal("FIN")
|
||||
expect(MeterbusLibUtils.manufCode(new Uint8Array([0x2e, 0x19]))).to.equal("FIN")
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user