web3.js/test/utils.fromUtf8.js

21 lines
696 B
JavaScript
Raw Normal View History

2015-08-10 20:11:37 +00:00
var chai = require('chai');
var BigNumber = require('bignumber.js');
2015-10-08 02:09:51 +00:00
var utils = require('../lib/utils/utils.js');
2015-08-10 20:11:37 +00:00
var assert = chai.assert;
var tests = [
{ value: 'myString', expected: '0x6d79537472696e67'},
{ value: 'myString\x00', expected: '0x6d79537472696e67'},
{ value: 'expected value\u0000\u0000\u0000', expected: '0x65787065637465642076616c7565'}
2015-08-10 20:11:37 +00:00
];
describe('lib/utils/utils', function () {
describe('fromUtf8', function () {
tests.forEach(function (test) {
it('should turn ' + test.value + ' to ' + test.expected, function () {
2015-10-08 02:09:51 +00:00
assert.strictEqual(utils.fromUtf8(test.value), test.expected);
2015-08-10 20:11:37 +00:00
});
});
});
});