Skip to content

Commit

Permalink
💚 Increase unit tests timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardstanislas committed Mar 23, 2023
1 parent 0872f26 commit defa3f9
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions src/lib/crypto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,42 @@ import {
} from '$lib/crypto';
import { describe, it, expect } from 'vitest';

describe('The crypto module', () => {
const content = 'La barbe de la femme à Georges Moustaki';
describe(
'The crypto module',
() => {
const content = 'La barbe de la femme à Georges Moustaki';

it('generates keypairs', async () => {
const keyPair = await generateKeyPair();
expect(keyPair.privateKey).toBeDefined();
expect(keyPair.publicKey).toBeDefined();
});
it('generates keypairs', async () => {
const keyPair = await generateKeyPair();
expect(keyPair.privateKey).toBeDefined();
expect(keyPair.publicKey).toBeDefined();
});

it('encrypts content that can be decrypted', async () => {
const keyPair = await generateKeyPair();
it('encrypts content that can be decrypted', async () => {
const keyPair = await generateKeyPair();

const encryptedContent = await encryptContent(content, keyPair.publicKey);
const encryptedContent = await encryptContent(content, keyPair.publicKey);

expect(encryptedContent).toBeDefined();
expect(encryptedContent).toBeDefined();

const decryptedContent = await decryptContent(encryptedContent, keyPair.privateKey);
const decryptedContent = await decryptContent(encryptedContent, keyPair.privateKey);

expect(decryptedContent).toBe(content);
});
expect(decryptedContent).toBe(content);
});

it('exports and imports keypairs', async () => {
const keyPair = await generateKeyPair();
it('exports and imports keypairs', async () => {
const keyPair = await generateKeyPair();

const exportedKeyPair = await keyPairToString(keyPair);
expect(exportedKeyPair).toBeDefined();
const exportedKeyPair = await keyPairToString(keyPair);
expect(exportedKeyPair).toBeDefined();

const importedKeyPair = await stringToKeyPair(exportedKeyPair);
expect(importedKeyPair).toBeDefined();
const importedKeyPair = await stringToKeyPair(exportedKeyPair);
expect(importedKeyPair).toBeDefined();

const encryptedContent = await encryptContent(content, keyPair.publicKey);
const decryptedContent = await decryptContent(encryptedContent, importedKeyPair.privateKey);
expect(decryptedContent).toBe(content);
});
});
const encryptedContent = await encryptContent(content, keyPair.publicKey);
const decryptedContent = await decryptContent(encryptedContent, importedKeyPair.privateKey);
expect(decryptedContent).toBe(content);
});
},
{ timeout: 10000 }
);

1 comment on commit defa3f9

@vercel
Copy link

@vercel vercel bot commented on defa3f9 Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.