web3.js/test/utils.toUtf8.js

23 lines
948 B
JavaScript
Raw Normal View History

2015-08-10 22:11:37 +02:00
var chai = require('chai');
var utils = require('../packages/web3-utils');
2015-08-10 22:11:37 +02:00
var assert = chai.assert;
var tests = [
2017-03-02 16:20:39 +01:00
{ value: '0x486565c3a4c3b6c3b6c3a4f09f9185443334c99dc9a33234d084cdbd2d2e2cc3a4c3bc2b232f', expected: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/'},
2015-08-10 22:11:37 +02:00
{ value: '0x6d79537472696e67', expected: 'myString'},
{ value: '0x6d79537472696e6700', expected: 'myString'},
{ value: '0x65787065637465642076616c7565000000000000000000000000000000000000', expected: 'expected value'},
{ value: '0x000000000000000000000000000000000000657870656374000065642076616c7565', expected: 'expect\u0000\u0000ed value'}
2015-08-10 22:11:37 +02:00
];
describe('lib/utils/utils', function () {
2017-03-15 16:18:20 +01:00
describe('hexToUtf8', function () {
2015-08-10 22:11:37 +02:00
tests.forEach(function (test) {
it('should turn ' + test.value + ' to ' + test.expected, function () {
2015-10-08 04:09:51 +02:00
assert.strictEqual(utils.toUtf8(test.value), test.expected);
2015-08-10 22:11:37 +02:00
});
});
});
});