-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): Add helper function for constructing a bit string
- Loading branch information
1 parent
c52c5d4
commit a3c6f48
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const utils = require('./utils'); | ||
const baEnum = require('../../lib/enum'); | ||
const client = require('../../lib/client'); | ||
|
||
describe('bacstack - client', () => { | ||
it('should successfuly encode a bitstring > 32 bits', () => { | ||
const result = client.createBitstring([ | ||
baEnum.ServicesSupported.CONFIRMED_COV_NOTIFICATION, | ||
baEnum.ServicesSupported.READ_PROPERTY, | ||
baEnum.ServicesSupported.WHO_IS, | ||
]); | ||
expect(result).to.deep.equal({ | ||
value: [2, 16, 0, 0, 4], | ||
bitsUsed: 35, | ||
}); | ||
}); | ||
it('should successfuly encode a bitstring < 8 bits', () => { | ||
const result = client.createBitstring([ | ||
baEnum.ServicesSupported.GET_ALARM_SUMMARY, | ||
]); | ||
expect(result).to.deep.equal({ | ||
value: [8], | ||
bitsUsed: 4, | ||
}); | ||
}); | ||
it('should successfuly encode a bitstring of only one bit', () => { | ||
const result = client.createBitstring([ | ||
baEnum.ServicesSupported.ACKNOWLEDGE_ALARM, | ||
]); | ||
expect(result).to.deep.equal({ | ||
value: [1], | ||
bitsUsed: 1, | ||
}); | ||
}); | ||
}); |