Add all BENNC message types with unit tests

This commit is contained in:
Jack Hadrill
2022-02-06 20:34:13 +00:00
parent 7d1a0991e4
commit e758de7ef4
28 changed files with 708 additions and 12539 deletions

View File

@@ -0,0 +1,19 @@
import { numberToUint16BE, numberToUint32BE } from '../../src/utilities/number'
test('Test number conversion to Uint16 big endian buffer.', () => {
// When
const result = numberToUint16BE(1234)
// Then
const expectedResult = Buffer.from([0x04, 0xd2])
expect(result).toMatchObject(expectedResult)
})
test('Test number conversion to Uint32 big endian buffer.', () => {
// When
const result = numberToUint32BE(123456)
// Then
const expectedResult = Buffer.from([0x00, 0x01, 0xE2, 0x40])
expect(result).toMatchObject(expectedResult)
})