diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2017-03-08 02:37:31 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2017-03-08 02:37:31 +0800 |
commit | 08ca7dac5a15e104084c6da3eb6015136b316809 (patch) | |
tree | 3e0b1a61f3be3aa1e01824512b4df0a793dc6a17 /test | |
parent | 01f2ec4823e83d986e7ecfd268f6b293f38a13e8 (diff) | |
parent | 2acf991b67bc42fb904ff77af6ff6a7ca3a683fd (diff) | |
download | tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.tar.gz tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.tar.zst tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.zip |
Merge branch 'master' into i1144-moarrpc
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/components/binary-renderer-test.js | 25 | ||||
-rw-r--r-- | test/unit/personal-message-manager-test.js | 23 |
2 files changed, 47 insertions, 1 deletions
diff --git a/test/unit/components/binary-renderer-test.js b/test/unit/components/binary-renderer-test.js new file mode 100644 index 000000000..3264faddc --- /dev/null +++ b/test/unit/components/binary-renderer-test.js @@ -0,0 +1,25 @@ +var assert = require('assert') +var BinaryRenderer = require('../../../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) + }) +}) diff --git a/test/unit/personal-message-manager-test.js b/test/unit/personal-message-manager-test.js index 657d5e675..77e1656c5 100644 --- a/test/unit/personal-message-manager-test.js +++ b/test/unit/personal-message-manager-test.js @@ -4,7 +4,7 @@ const EventEmitter = require('events') const PersonalMessageManager = require('../../app/scripts/lib/personal-message-manager') -describe('Transaction Manager', function() { +describe('Personal Message Manager', function() { let messageManager beforeEach(function() { @@ -86,4 +86,25 @@ describe('Transaction Manager', function() { assert.equal(messageManager.getMsg('2').status, 'approved') }) }) + + describe('#normalizeMsgData', function() { + it('converts text to a utf8 buffer', function() { + var input = 'hello' + var output = messageManager.normalizeMsgData(input) + assert.equal(output, '0x68656c6c6f', 'predictably hex encoded') + }) + + it('tolerates a hex prefix', function() { + var input = '0x12' + var output = messageManager.normalizeMsgData(input) + assert.equal(output, '0x12', 'un modified') + }) + + it('tolerates normal hex', function() { + var input = '12' + var output = messageManager.normalizeMsgData(input) + assert.equal(output, '0x12', 'adds prefix') + }) + }) + }) |