Convert all tests to TypeScript

This commit is contained in:
Alex Gleason
2023-05-10 16:10:19 -05:00
committed by fiatjaf_
parent 64caef9cda
commit 18e8227123
32 changed files with 439 additions and 405 deletions

17
nip04.test.ts Normal file
View File

@@ -0,0 +1,17 @@
import {nip04, getPublicKey, generatePrivateKey} from '.'
import crypto from 'crypto'
// @ts-ignore
// eslint-disable-next-line no-undef
globalThis.crypto = crypto
test('encrypt and decrypt message', async () => {
let sk1 = generatePrivateKey()
let sk2 = generatePrivateKey()
let pk1 = getPublicKey(sk1)
let pk2 = getPublicKey(sk2)
expect(
await nip04.decrypt(sk2, pk1, await nip04.encrypt(sk1, pk2, 'hello'))
).toEqual('hello')
})