This commit is contained in:
parent
46eb5ee233
commit
b053cf12e3
14
jasmine.json
Normal file
14
jasmine.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"spec_dir": "test",
|
||||||
|
"spec_files": [
|
||||||
|
"spec/*.js",
|
||||||
|
"spec/*.ts"
|
||||||
|
],
|
||||||
|
"helpers": [
|
||||||
|
"helpers/*.js",
|
||||||
|
"helpers/*.ts"
|
||||||
|
],
|
||||||
|
"stopSpecOnExpectationFailure": false,
|
||||||
|
"random": false
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sapphirecode/encoding-helper",
|
"name": "@sapphirecode/encoding-helper",
|
||||||
"version": "1.0.49",
|
"version": "1.0.50",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Timo Hocker",
|
"name": "Timo Hocker",
|
||||||
@ -19,14 +19,17 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sapphirecode/eslint-config": "^2.1.4",
|
"@sapphirecode/eslint-config": "^2.1.4",
|
||||||
"@stryker-mutator/core": "^3.2.3",
|
"@stryker-mutator/core": "^3.2.3",
|
||||||
|
"@stryker-mutator/jasmine-framework": "^3.3.1",
|
||||||
|
"@stryker-mutator/jasmine-runner": "^3.3.1",
|
||||||
"@stryker-mutator/javascript-mutator": "^3.2.3",
|
"@stryker-mutator/javascript-mutator": "^3.2.3",
|
||||||
"ava": "^3.8.2",
|
"@types/jasmine": "^3.5.14",
|
||||||
"eslint": "^7.0.0",
|
"eslint": "^7.0.0",
|
||||||
|
"jasmine": "^3.6.1",
|
||||||
"nyc": "^15.0.1"
|
"nyc": "^15.0.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
||||||
"test": "nyc ava",
|
"test": "nyc jasmine --config=\"jasmine.json\"",
|
||||||
"mutate": "stryker run",
|
"mutate": "stryker run",
|
||||||
"compile": "tsc --allowJs --declaration --emitDeclarationOnly index.js"
|
"compile": "tsc --allowJs --declaration --emitDeclarationOnly index.js"
|
||||||
},
|
},
|
||||||
|
@ -17,8 +17,10 @@ module.exports = {
|
|||||||
'clear-text',
|
'clear-text',
|
||||||
'progress'
|
'progress'
|
||||||
],
|
],
|
||||||
testRunner: 'command',
|
testRunner: 'jasmine',
|
||||||
|
testFramework: 'jasmine',
|
||||||
|
jasmineConfigFile: 'jasmine.json',
|
||||||
transpilers: [],
|
transpilers: [],
|
||||||
coverageAnalysis: 'all',
|
coverageAnalysis: 'perTest',
|
||||||
mutate: [ 'index.js' ]
|
mutate: [ 'index.js' ]
|
||||||
};
|
};
|
||||||
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user