mirror of
https://github.com/cupcakearmy/occulto.git
synced 2025-09-09 12:00:42 +00:00
cleanup test infra
This commit is contained in:
38
test/encoding.spec.ts
Normal file
38
test/encoding.spec.ts
Normal 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)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user