Timo Hocker
2e9c3896a5
All checks were successful
continuous-integration/drone/push Build is passing
69 lines
1.5 KiB
JavaScript
69 lines
1.5 KiB
JavaScript
/*
|
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
|
* This file is part of encoding-helper which is released under MIT.
|
|
* See file 'LICENSE' for full license details.
|
|
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
|
*/
|
|
|
|
// @ts-nocheck
|
|
/* eslint-disable no-magic-numbers */
|
|
'use strict';
|
|
|
|
const encoding = require ('../../index');
|
|
|
|
describe ('encoding', () => {
|
|
it ('encoding to_hex', () => {
|
|
const hex = encoding.to_hex ('foo');
|
|
expect (hex)
|
|
.toEqual ('666f6f');
|
|
});
|
|
|
|
it ('encoding to_b64', () => {
|
|
const hex = encoding.to_b64 ('foo');
|
|
expect (hex)
|
|
.toEqual ('Zm9v');
|
|
});
|
|
|
|
it ('encoding to_b58', () => {
|
|
const hex = encoding.to_b58 ('foo');
|
|
expect (hex)
|
|
.toEqual ('bQbp');
|
|
});
|
|
|
|
it ('encoding to_utf8', () => {
|
|
const utf = encoding.to_utf8 ('Zm9v', 'base64');
|
|
expect (utf)
|
|
.toEqual ('foo');
|
|
});
|
|
|
|
it ('encoding to_utf8 from b58', () => {
|
|
const utf = encoding.to_utf8 ('bQbp', 'base58');
|
|
expect (utf)
|
|
.toEqual ('foo');
|
|
});
|
|
|
|
it ('convert num to hex', () => {
|
|
const res = encoding.num_to_hex (11);
|
|
expect (res)
|
|
.toEqual ('b');
|
|
});
|
|
|
|
it ('convert num to hex padded', () => {
|
|
const res = encoding.num_to_hex (11, 2);
|
|
expect (res)
|
|
.toEqual ('0b');
|
|
});
|
|
|
|
it ('convert hex to num', () => {
|
|
const res = encoding.hex_to_num ('b');
|
|
expect (res)
|
|
.toEqual (11);
|
|
});
|
|
|
|
it ('convert hex padded to num', () => {
|
|
const res = encoding.hex_to_num ('0b');
|
|
expect (res)
|
|
.toEqual (11);
|
|
});
|
|
});
|