replace number[] by Uint8Array
This commit is contained in:
@ -43,6 +43,8 @@ let inputNOKLongframe_too_short = "68 02 02 68 01 02 03 16"
|
||||
|
||||
let inputNOk_wrong_startcode = "15 01 02 03 16"
|
||||
|
||||
let inputNOk_illegal_number = "10 01 260 03 16"
|
||||
|
||||
|
||||
|
||||
describe('The Meterbus Library', () => {
|
||||
@ -54,7 +56,7 @@ describe('The Meterbus Library', () => {
|
||||
it('should parse the hexString into the telegram array', () => {
|
||||
const telegram = new MeterbusLib.Telegram()
|
||||
telegram.fromHexString("01 02 03")
|
||||
expect(telegram.telegram).to.deep.equal([1, 2, 3])
|
||||
expect(telegram.telegram).to.deep.equal(new Uint8Array([1, 2, 3]))
|
||||
})
|
||||
it('should detect a control frame', () => {
|
||||
const telegram = new MeterbusLib.Telegram()
|
||||
@ -105,6 +107,10 @@ describe('The Meterbus Library', () => {
|
||||
telegram.fromHexString(inputNOKLongframe_too_short)
|
||||
expect(() => telegram.parse()).to.throw(MeterbusLibExceptions.PayloadTooShortError)
|
||||
})
|
||||
it('should detect an invalid number', () => {
|
||||
const telegram = new MeterbusLib.Telegram()
|
||||
expect(() => telegram.fromHexString(inputNOk_illegal_number)).to.throw(MeterbusLibExceptions.IllegalNumberError)
|
||||
})
|
||||
it('should parse cField from a short frame', () => {
|
||||
const telegram = new MeterbusLib.Telegram()
|
||||
telegram.fromHexString(inputOkShortframe)
|
||||
@ -171,7 +177,7 @@ describe('The Meterbus Library', () => {
|
||||
})
|
||||
it('should find the signature', () => {
|
||||
expect((telegram.frame as MeterbusLibLongFrame.LongFrame).fixedDataHeader.signature)
|
||||
.to.deep.equal([0,0])
|
||||
.to.deep.equal(new Uint8Array([0,0]))
|
||||
})
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user