Adapt tests

This commit is contained in:
2024-09-11 23:13:55 +02:00
parent a0ffa2f682
commit a26dd305f8
8 changed files with 58 additions and 29 deletions
+6 -3
View File
@@ -14,12 +14,14 @@ beforeAll(async () => {
test('base case', async () => {
const box = await PrivateWrap.wrap(message, k1.publicKey)
const unboxed = await box.unwrap(k1.privateKey)
expect(box).not.toBeNull()
const unboxed = await box!.unwrap(k1.privateKey)
expect(unboxed).toEqual(message)
})
test("Different key can't decrypt", async () => {
const box = await PrivateWrap.wrap(message, k1.publicKey)
const unboxed = await box.unwrap(k2.privateKey)
expect(box).not.toBeNull()
const unboxed = await box!.unwrap(k2.privateKey)
expect(unboxed).toBeNull()
})
@@ -36,8 +38,9 @@ test('Key generation', async () => {
test('serialization', async () => {
const box = await PrivateWrap.wrap(message, k1.publicKey)
expect(box).not.toBeNull()
const ser = await box.toString()
const ser = await box!.toString()
const de = await PrivateWrap.fromString(ser)
expect(de).not.toBeNull()