2017-03-07 00:03:49 +01:00
|
|
|
var assert = require('assert')
|
2018-03-19 16:11:24 +01:00
|
|
|
var BinaryRenderer = require('../../../old-ui/app/components/binary-renderer')
|
2017-03-07 00:03:49 +01:00
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
describe('BinaryRenderer', function () {
|
2017-03-07 00:03:49 +01:00
|
|
|
let binaryRenderer
|
|
|
|
const message = 'Hello, world!'
|
2018-10-09 14:02:48 +02:00
|
|
|
const buffer = Buffer.from(message, 'utf8')
|
2017-03-07 00:03:49 +01:00
|
|
|
const hex = buffer.toString('hex')
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
beforeEach(function () {
|
2017-03-07 00:03:49 +01:00
|
|
|
binaryRenderer = new BinaryRenderer()
|
|
|
|
})
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
it('recovers message', function () {
|
2017-03-07 00:03:49 +01:00
|
|
|
const result = binaryRenderer.hexToText(hex)
|
|
|
|
assert.equal(result, message)
|
|
|
|
})
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
it('recovers message with hex prefix', function () {
|
2017-03-07 00:03:49 +01:00
|
|
|
const result = binaryRenderer.hexToText('0x' + hex)
|
|
|
|
assert.equal(result, message)
|
|
|
|
})
|
|
|
|
})
|