Test contexts
This commit is contained in:
@@ -36,6 +36,22 @@ test('Key generation', async () => {
|
||||
expect(k2.publicKey.extractable).toBeTrue()
|
||||
})
|
||||
|
||||
test('Encrypt with context', async () => {
|
||||
const context = 'Super context !'
|
||||
const box = await PrivateBox.encrypt(message, k1.publicKey, context)
|
||||
expect(box).not.toBeNull()
|
||||
const unboxed = await box!.decrypt(k1.privateKey, context)
|
||||
expect(unboxed).toEqual(message)
|
||||
})
|
||||
test('Encrypt with different context', async () => {
|
||||
const context1 = 'Super context !'
|
||||
const context2 = 'Awesome context !'
|
||||
const box = await PrivateBox.encrypt(message, k1.publicKey, context1)
|
||||
expect(box).not.toBeNull()
|
||||
const unboxed = await box!.decrypt(k1.privateKey, context2)
|
||||
expect(unboxed).toBeNull()
|
||||
})
|
||||
|
||||
test('serialization', async () => {
|
||||
const box = await PrivateBox.encrypt(message, k1.publicKey)
|
||||
expect(box).not.toBeNull()
|
||||
|
||||
Reference in New Issue
Block a user