This commit is contained in:
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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 test = require ('ava');
|
||||
const encoding = require ('../index');
|
||||
|
||||
|
||||
test ('encoding to_hex', (t) => {
|
||||
const hex = encoding.to_hex ('foo');
|
||||
t.is (hex, '666f6f');
|
||||
});
|
||||
|
||||
test ('encoding to_b64', (t) => {
|
||||
const hex = encoding.to_b64 ('foo');
|
||||
t.is (hex, 'Zm9v');
|
||||
});
|
||||
|
||||
test ('encoding to_utf8', (t) => {
|
||||
const utf = encoding.to_utf8 ('Zm9v', 'base64');
|
||||
t.is (utf, 'foo');
|
||||
});
|
||||
|
||||
test ('convert num to hex', (t) => {
|
||||
const res = encoding.num_to_hex (11);
|
||||
t.is (res, 'b');
|
||||
});
|
||||
|
||||
test ('convert num to hex padded', (t) => {
|
||||
const res = encoding.num_to_hex (11, 2);
|
||||
t.is (res, '0b');
|
||||
});
|
||||
|
||||
test ('convert hex to num', (t) => {
|
||||
const res = encoding.hex_to_num ('b');
|
||||
t.is (res, 11);
|
||||
});
|
||||
|
||||
test ('convert hex padded to num', (t) => {
|
||||
const res = encoding.hex_to_num ('0b');
|
||||
t.is (res, 11);
|
||||
});
|
57
test/spec/index.js
Normal file
57
test/spec/index.js
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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_utf8', () => {
|
||||
const utf = encoding.to_utf8 ('Zm9v', 'base64');
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user