bennc-js/tests/messages/subscribe.test.ts
Jack Hadrill e758de7ef4
Some checks failed
continuous-integration/drone/push Build is failing
Add all BENNC message types with unit tests
2022-02-06 20:38:52 +00:00

15 lines
423 B
TypeScript

import { MessageTypes } from '../../src/common'
import { packers } from '../../src/mapping'
test('Create a subscribe (0x0000) packet.', () => {
// Given
const messageType = 0xabcd
// When
const packedPacket = packers[MessageTypes.Subscribe]({ messageType: messageType })
// Then
const expectedResult = Buffer.from([0x00, 0x00, 0x00, 0x02, 0xab, 0xcd])
expect(packedPacket).toMatchObject(expectedResult)
})