Files
xahau.js/packages/xrpl/test/utils/hexConversion.ts
Jackson Mills 89b8833610 Fix Windows contributors being unable to build and test the xrpl mono repo (#1822)
* Let ripple-binary-codec to build on windows & nix

Co-authored-by: Justintime <justinthenicholasoftime@protonmail.com>
2021-11-23 12:29:06 -08:00

29 lines
871 B
TypeScript

import { assert } from 'chai'
import { convertHexToString, convertStringToHex } from 'xrpl-local/utils'
describe('convertHexToString and convertStringToHex', function () {
it('converts "example.com"', function () {
const str = 'example.com'
const hex = convertStringToHex(str)
assert.strictEqual(
hex,
'6578616D706C652E636F6D',
'should convert to hex equivalent',
)
const result = convertHexToString(hex)
assert.strictEqual(
result,
'example.com',
'should convert back to example.com',
)
})
it('converts "你好"', function () {
const str = '你好'
const hex = convertStringToHex(str)
assert.strictEqual(hex, 'E4BDA0E5A5BD', 'should convert to hex equivalent')
const result = convertHexToString(hex)
assert.strictEqual(result, '你好', 'should convert back to 你好')
})
})