2021-10-14 19:34:10 +07:00
|
|
|
import binaryToHex from '../BinaryToHex'
|
|
|
|
|
|
|
|
|
|
describe('BinaryToHex', () => {
|
|
|
|
|
it('expects to return correct hexadecimal value', () => {
|
|
|
|
|
expect(binaryToHex('1000')).toBe('8')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('expects to return correct hexadecimal value for more than one hex digit', () => {
|
|
|
|
|
expect(binaryToHex('11101010')).toBe('EA')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('expects to return correct hexadecimal value for padding-required binary', () => {
|
|
|
|
|
expect(binaryToHex('1001101')).toBe('4D')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('expects to return correct hexadecimal value, matching (num).toString(16)', () => {
|
2023-10-03 23:08:19 +02:00
|
|
|
expect(binaryToHex('1111')).toBe(
|
|
|
|
|
parseInt('1111', 2).toString(16).toUpperCase()
|
|
|
|
|
)
|
2021-10-14 19:34:10 +07:00
|
|
|
})
|
|
|
|
|
})
|