Adapt tests
This commit is contained in:
@@ -14,12 +14,14 @@ beforeAll(async () => {
|
||||
|
||||
test('base case', async () => {
|
||||
const box = await PrivateBox.encrypt(message, k1.publicKey)
|
||||
const unboxed = await box.decrypt(k1.privateKey)
|
||||
expect(box).not.toBeNull()
|
||||
const unboxed = await box!.decrypt(k1.privateKey)
|
||||
expect(unboxed).toEqual(message)
|
||||
})
|
||||
test("Different key can't decrypt", async () => {
|
||||
const box = await PrivateBox.encrypt(message, k1.publicKey)
|
||||
const unboxed = await box.decrypt(k2.privateKey)
|
||||
expect(box).not.toBeNull()
|
||||
const unboxed = await box!.decrypt(k2.privateKey)
|
||||
expect(unboxed).toBeNull()
|
||||
})
|
||||
|
||||
@@ -36,8 +38,9 @@ test('Key generation', async () => {
|
||||
|
||||
test('serialization', async () => {
|
||||
const box = await PrivateBox.encrypt(message, k1.publicKey)
|
||||
expect(box).not.toBeNull()
|
||||
|
||||
const ser = await box.toString()
|
||||
const ser = await box!.toString()
|
||||
const de = await PrivateBox.fromString(ser)
|
||||
|
||||
expect(de).not.toBeNull()
|
||||
|
||||
Reference in New Issue
Block a user