Tests for generateKeyPair()
This commit is contained in:
parent
9fb2af4d33
commit
45c599794b
1 changed files with 24 additions and 0 deletions
24
utils/ECC/ECC.spec.js
Normal file
24
utils/ECC/ECC.spec.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
const expect = require('expect')
|
||||||
|
|
||||||
|
const { generateKeyPair } = require('./ECC')
|
||||||
|
|
||||||
|
describe('generateKeyPair()', () => {
|
||||||
|
it('generates a keypair', () => {
|
||||||
|
const pair = generateKeyPair()
|
||||||
|
|
||||||
|
expect(pair.privateKey).toBeInstanceOf(Buffer)
|
||||||
|
expect(typeof pair.privateKeyBase64 === 'string').toBeTruthy()
|
||||||
|
expect(pair.publicKey).toBeInstanceOf(Buffer)
|
||||||
|
expect(typeof pair.publicKeyBase64 === 'string').toBeTruthy()
|
||||||
|
})
|
||||||
|
it('returns the same pair for the same device', () => {
|
||||||
|
const id = 'fbuiio3089fhfunjancj,'
|
||||||
|
const pair = generateKeyPair(id)
|
||||||
|
const pairAgain = generateKeyPair(id)
|
||||||
|
|
||||||
|
expect(pairAgain).toStrictEqual(pair)
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue