@@ -18,22 +18,26 @@ import { decodeRecoveryKey, encodeRecoveryKey } from "../../../src/crypto-api";
18
18
19
19
describe ( "recovery key" , ( ) => {
20
20
describe ( "decodeRecoveryKey" , ( ) => {
21
- it ( "should thrown an incorrect parity" , ( ) => {
22
- expect ( ( ) => decodeRecoveryKey ( "alice" ) ) . toThrow ( "Incorrect parity" ) ;
23
- } ) ;
24
-
25
21
it ( "should thrown an incorrect length error" , ( ) => {
26
22
const key = [ 0 , 1 ] ;
27
- const encodedKey = encodeRecoveryKey ( key ) ;
23
+ const encodedKey = encodeRecoveryKey ( key ) ! ;
24
+
25
+ expect ( ( ) => decodeRecoveryKey ( encodedKey ) ) . toThrow ( "Incorrect length" ) ;
26
+ } ) ;
27
+
28
+ it ( "should thrown an incorrect parity" , ( ) => {
29
+ const key = Array . from ( { length : 32 } , ( _ , i ) => i ) ;
30
+ let encodedKey = encodeRecoveryKey ( key ) ! ;
31
+ encodedKey = encodedKey . replace ( "EsSz" , "EsSZ" ) ;
28
32
29
- expect ( ( ) => decodeRecoveryKey ( encodedKey ! ) ) . toThrow ( "Incorrect length " ) ;
33
+ expect ( ( ) => decodeRecoveryKey ( encodedKey ! ) ) . toThrow ( "Incorrect parity " ) ;
30
34
} ) ;
31
35
32
36
it ( "should decode a valid encoded key" , ( ) => {
33
37
const key = Array . from ( { length : 32 } , ( _ , i ) => i ) ;
34
- const encodedKey = encodeRecoveryKey ( key ) ;
38
+ const encodedKey = encodeRecoveryKey ( key ) ! ;
35
39
36
- expect ( decodeRecoveryKey ( encodedKey ! ) ) . toEqual ( new Uint8Array ( key ) ) ;
40
+ expect ( decodeRecoveryKey ( encodedKey ) ) . toEqual ( new Uint8Array ( key ) ) ;
37
41
} ) ;
38
42
} ) ;
39
43
} ) ;
0 commit comments