aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/components/binary-renderer-test.js
blob: 7bf9250cc5f9722840d96f380a1d75fecb6ebd74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var assert = require('assert')
var BinaryRenderer = require('../../../old-ui/app/components/binary-renderer')

describe('BinaryRenderer', function () {
  let binaryRenderer
  const message = 'Hello, world!'
  const buffer = new Buffer(message, 'utf8')
  const hex = buffer.toString('hex')

  beforeEach(function () {
    binaryRenderer = new BinaryRenderer()
  })

  it('recovers message', function () {
    const result = binaryRenderer.hexToText(hex)
    assert.equal(result, message)
  })

  it('recovers message with hex prefix', function () {
    const result = binaryRenderer.hexToText('0x' + hex)
    assert.equal(result, message)
  })
})