cleanup test infra

This commit is contained in:
2024-07-29 16:14:12 +02:00
parent 72a31ab3e2
commit c485d5c715
18 changed files with 2247 additions and 1771 deletions

38
test/encoding.spec.ts Normal file
View File

@@ -0,0 +1,38 @@
import { describe, expect, it } from 'vitest'
import { Base64, Bytes, Hex } from '../dist/index.js'
import { Precomputed } from './values.js'
describe('Encoding', () => {
describe('Bytes', () => {
for (const [input, output] of Object.entries(Precomputed.Encoding.Bytes)) {
it(`Should encode ${input} to ${output}`, async () => {
expect(Bytes.encode(input).buffer).toEqual(output.buffer)
})
it(`Should decode ${output} to ${input}`, async () => {
expect(Bytes.decode(output)).toEqual(input)
})
}
})
describe('Hex', () => {
for (const [input, output] of Object.entries(Precomputed.Encoding.Hex)) {
const buffer = Bytes.encode(input)
it(`Should encode ${input} to ${output}`, async () => {
expect(Hex.encode(buffer)).toEqual(output)
})
it(`Should decode ${output} to ${input}`, async () => {
expect(Hex.decode(output).buffer).toEqual(buffer.buffer)
})
}
})
describe('Base64', () => {
for (const [input, output] of Object.entries(Precomputed.Encoding.Base64)) {
const buffer = Bytes.encode(input)
it(`Should encode ${input} to ${output}`, async () => {
expect(await Base64.encode(buffer)).toEqual(output)
})
it(`Should decode ${output} to ${input}`, async () => {
expect((await Base64.decode(output)).buffer).toEqual(buffer.buffer)
})
}
})
})