Implement misc and tests

This commit is contained in:
2024-05-14 11:31:56 +02:00
commit cde473540a
5 changed files with 110 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import {a2b64, a2str, b642a, str2a} from './index'
import {test, expect} from 'bun:test'
test('str2a and a2str are reciprocal', () => {
const from = "Testing value !"
let buff = str2a(from)
let to = a2str(buff)
expect(to).toBe(from)
})
test('b642a and a2b64 are reciprocal', () => {
const from_str = "Testing value !"
const from = btoa(from_str)
let buff = b642a(from).expect("Should encode valid b64")
let to = a2b64(buff)
expect(to).toBe(from)
})
test("b642a doesn't accept invalid b64", () => {
b642a("pa'0ac'i !!").expect_err("Shouldn't unpack invalid b64")
})