Use top level describe()
This commit is contained in:
parent
0166636ccc
commit
5542d7b8db
2 changed files with 102 additions and 98 deletions
|
|
@ -24,7 +24,8 @@ const storageDirectory = Path.resolve(__dirname, `./.test-storage`)
|
||||||
|
|
||||||
console.log(`Storage directory: ${storageDirectory}`)
|
console.log(`Storage directory: ${storageDirectory}`)
|
||||||
|
|
||||||
describe('generateKeyPair()', () => {
|
describe('ECC', () => {
|
||||||
|
describe('generateKeyPair()', () => {
|
||||||
it('generates a keypair', async () => {
|
it('generates a keypair', async () => {
|
||||||
expect.hasAssertions()
|
expect.hasAssertions()
|
||||||
const pair = await generateKeyPair(uuid())
|
const pair = await generateKeyPair(uuid())
|
||||||
|
|
@ -42,9 +43,9 @@ describe('generateKeyPair()', () => {
|
||||||
|
|
||||||
expect(pairAgain).toStrictEqual(pair)
|
expect(pairAgain).toStrictEqual(pair)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('authorizeDevice()/isAuthorizedDevice()', () => {
|
describe('authorizeDevice()/isAuthorizedDevice()', () => {
|
||||||
it('authorizes a device given its ID', async () => {
|
it('authorizes a device given its ID', async () => {
|
||||||
expect.hasAssertions()
|
expect.hasAssertions()
|
||||||
await Storage.init({
|
await Storage.init({
|
||||||
|
|
@ -55,9 +56,9 @@ describe('authorizeDevice()/isAuthorizedDevice()', () => {
|
||||||
await authorizeDevice({ deviceId, publicKey: pair.publicKeyBase64 })
|
await authorizeDevice({ deviceId, publicKey: pair.publicKeyBase64 })
|
||||||
expect(isAuthorizedDevice({ deviceId })).toBeTruthy()
|
expect(isAuthorizedDevice({ deviceId })).toBeTruthy()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('encryptMessage()/decryptMessage()', () => {
|
describe('encryptMessage()/decryptMessage()', () => {
|
||||||
before(() =>
|
before(() =>
|
||||||
Storage.init({
|
Storage.init({
|
||||||
dir: storageDirectory
|
dir: storageDirectory
|
||||||
|
|
@ -116,4 +117,5 @@ describe('encryptMessage()/decryptMessage()', () => {
|
||||||
|
|
||||||
expect(decrypted).toEqual(message)
|
expect(decrypted).toEqual(message)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ const {
|
||||||
convertBufferToBase64
|
convertBufferToBase64
|
||||||
} = require('./crypto')
|
} = require('./crypto')
|
||||||
|
|
||||||
describe('generateRandomString()', () => {
|
describe('crypto', () => {
|
||||||
|
describe('generateRandomString()', () => {
|
||||||
it('creates a random string of the specified length', async () => {
|
it('creates a random string of the specified length', async () => {
|
||||||
expect.hasAssertions()
|
expect.hasAssertions()
|
||||||
const base = Math.ceil(Math.random() * 100)
|
const base = Math.ceil(Math.random() * 100)
|
||||||
|
|
@ -19,9 +20,9 @@ describe('generateRandomString()', () => {
|
||||||
|
|
||||||
expect(result.length).toEqual(len)
|
expect(result.length).toEqual(len)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Buffer <> String <> Buffer', () => {
|
describe('Buffer <> String <> Buffer', () => {
|
||||||
it('preserves values', async () => {
|
it('preserves values', async () => {
|
||||||
const rnd = await generateRandomString(24)
|
const rnd = await generateRandomString(24)
|
||||||
|
|
||||||
|
|
@ -31,4 +32,5 @@ describe('Buffer <> String <> Buffer', () => {
|
||||||
|
|
||||||
expect(asStringAgain).toEqual(rnd)
|
expect(asStringAgain).toEqual(rnd)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue