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('utf8ToHex', function () { tests.forEach(function (test) { it('should turn ' + test.value + ' to ' + test.expected, function () { assert.strictEqual(utils.fromUtf8(test.value), test.expected); }); }); }); });