From 211d5f7629fb2b824ca131af628052dbd87ade0b Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Tue, 18 Oct 2022 16:59:33 +0200 Subject: [PATCH] add tests for hex --- test/encoding.spec.js | 13 ++++++++++++- test/values.js | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/encoding.spec.js b/test/encoding.spec.js index abf8ee3..07a5649 100644 --- a/test/encoding.spec.js +++ b/test/encoding.spec.js @@ -1,7 +1,18 @@ -import { Base64, Bytes } from '../dist/index.js' +import { Base64, Bytes, Hex } from '../dist/index.js' import { Precomputed } from './values.js' describe('Encoding', () => { + describe('Hex', () => { + for (const [input, output] of Object.entries(Precomputed.Encoding.Hex)) { + const buffer = Bytes.encode(input) + it(`Should encode ${input} to ${output}`, async () => { + chai.expect(await Hex.encode(buffer)).to.equal(output) + }) + it(`Should decode ${output} to ${input}`, async () => { + chai.expect(await Hex.decode(output)).to.deep.equal(buffer) + }) + } + }) describe('Base64', () => { for (const [input, output] of Object.entries(Precomputed.Encoding.Base64)) { const buffer = Bytes.encode(input) diff --git a/test/values.js b/test/values.js index 6868d9b..12e81bb 100644 --- a/test/values.js +++ b/test/values.js @@ -5,6 +5,11 @@ export const Precomputed = { test: 'dGVzdA==', 'hello world': 'aGVsbG8gd29ybGQ=', }, + Hex: { + test: '74657374', + occulto: '6f6363756c746f', + 'hello world': '68656c6c6f20776f726c64', + }, }, Hash: { SHA_1: {