@@ -7,38 +7,42 @@ import {
7
7
} from '$lib/crypto' ;
8
8
import { describe , it , expect } from 'vitest' ;
9
9
10
- describe ( 'The crypto module' , ( ) => {
11
- const content = 'La barbe de la femme à Georges Moustaki' ;
10
+ describe (
11
+ 'The crypto module' ,
12
+ ( ) => {
13
+ const content = 'La barbe de la femme à Georges Moustaki' ;
12
14
13
- it ( 'generates keypairs' , async ( ) => {
14
- const keyPair = await generateKeyPair ( ) ;
15
- expect ( keyPair . privateKey ) . toBeDefined ( ) ;
16
- expect ( keyPair . publicKey ) . toBeDefined ( ) ;
17
- } ) ;
15
+ it ( 'generates keypairs' , async ( ) => {
16
+ const keyPair = await generateKeyPair ( ) ;
17
+ expect ( keyPair . privateKey ) . toBeDefined ( ) ;
18
+ expect ( keyPair . publicKey ) . toBeDefined ( ) ;
19
+ } ) ;
18
20
19
- it ( 'encrypts content that can be decrypted' , async ( ) => {
20
- const keyPair = await generateKeyPair ( ) ;
21
+ it ( 'encrypts content that can be decrypted' , async ( ) => {
22
+ const keyPair = await generateKeyPair ( ) ;
21
23
22
- const encryptedContent = await encryptContent ( content , keyPair . publicKey ) ;
24
+ const encryptedContent = await encryptContent ( content , keyPair . publicKey ) ;
23
25
24
- expect ( encryptedContent ) . toBeDefined ( ) ;
26
+ expect ( encryptedContent ) . toBeDefined ( ) ;
25
27
26
- const decryptedContent = await decryptContent ( encryptedContent , keyPair . privateKey ) ;
28
+ const decryptedContent = await decryptContent ( encryptedContent , keyPair . privateKey ) ;
27
29
28
- expect ( decryptedContent ) . toBe ( content ) ;
29
- } ) ;
30
+ expect ( decryptedContent ) . toBe ( content ) ;
31
+ } ) ;
30
32
31
- it ( 'exports and imports keypairs' , async ( ) => {
32
- const keyPair = await generateKeyPair ( ) ;
33
+ it ( 'exports and imports keypairs' , async ( ) => {
34
+ const keyPair = await generateKeyPair ( ) ;
33
35
34
- const exportedKeyPair = await keyPairToString ( keyPair ) ;
35
- expect ( exportedKeyPair ) . toBeDefined ( ) ;
36
+ const exportedKeyPair = await keyPairToString ( keyPair ) ;
37
+ expect ( exportedKeyPair ) . toBeDefined ( ) ;
36
38
37
- const importedKeyPair = await stringToKeyPair ( exportedKeyPair ) ;
38
- expect ( importedKeyPair ) . toBeDefined ( ) ;
39
+ const importedKeyPair = await stringToKeyPair ( exportedKeyPair ) ;
40
+ expect ( importedKeyPair ) . toBeDefined ( ) ;
39
41
40
- const encryptedContent = await encryptContent ( content , keyPair . publicKey ) ;
41
- const decryptedContent = await decryptContent ( encryptedContent , importedKeyPair . privateKey ) ;
42
- expect ( decryptedContent ) . toBe ( content ) ;
43
- } ) ;
44
- } ) ;
42
+ const encryptedContent = await encryptContent ( content , keyPair . publicKey ) ;
43
+ const decryptedContent = await decryptContent ( encryptedContent , importedKeyPair . privateKey ) ;
44
+ expect ( decryptedContent ) . toBe ( content ) ;
45
+ } ) ;
46
+ } ,
47
+ { timeout : 10000 }
48
+ ) ;
0 commit comments