Test contexts
This commit is contained in:
+16
-1
@@ -29,7 +29,7 @@ test('Key generation', async () => {
|
||||
expect(k2.extractable).toBeTrue()
|
||||
})
|
||||
|
||||
test('serialization', async () => {
|
||||
test('String serialization', async () => {
|
||||
const box = await SecretBox.encrypt(message, k1)
|
||||
expect(box).not.toBeNull()
|
||||
|
||||
@@ -43,3 +43,18 @@ test('serialization', async () => {
|
||||
expect(unboxed).not.toBeNull()
|
||||
expect(unboxed).toEqual(message)
|
||||
})
|
||||
|
||||
test('Byte serialization', async () => {
|
||||
const box = await SecretBox.encrypt(message, k1)
|
||||
expect(box).not.toBeNull()
|
||||
|
||||
const ser = box!.toBytes()
|
||||
const de = SecretBox.fromBytes(ser)
|
||||
|
||||
expect(de).not.toBeNull()
|
||||
expect(de).toEqual(box)
|
||||
|
||||
const unboxed = await de!.decrypt(k1)
|
||||
expect(unboxed).not.toBeNull()
|
||||
expect(unboxed).toEqual(message)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user