web3.js/test/utils.fromUtf8.js
2017-03-02 17:23:38 +01:00

23 lines
915 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var chai = require('chai');
var utils = require('../packages/web3-utils');
var assert = chai.assert;
var tests = [
{ value: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/', expected: '0x486565c3a4c3b6c3b6c3a4f09f9185443334c99dc9a33234d084cdbd2d2e2cc3a4c3bc2b232f'},
{ value: 'myString', expected: '0x6d79537472696e67'},
{ value: 'myString\x00', expected: '0x6d79537472696e67'},
{ value: 'expected value\u0000\u0000\u0000', expected: '0x65787065637465642076616c7565'},
{ value: 'expect\u0000\u0000ed value\u0000\u0000\u0000', expected: '0x657870656374000065642076616c7565'}
];
describe('lib/utils/utils', function () {
describe('fromUtf8', function () {
tests.forEach(function (test) {
it('should turn ' + test.value + ' to ' + test.expected, function () {
assert.strictEqual(utils.fromUtf8(test.value), test.expected);
});
});
});
});