@@ -127,25 +127,25 @@ describe("Libsodium", () => {
127127 } ;
128128
129129 // 8 bytes
130- await expectAsync (
131- Argon2id . execute ( password , fromHex ( "aabbccddeeff0011" ) , options ) ,
132- ) . toBeRejectedWithError ( / i n v a l i d s a l t l e n g t h / ) ;
130+ await expect ( Argon2id . execute ( password , fromHex ( "aabbccddeeff0011" ) , options ) ) . rejects . toThrowError (
131+ / i n v a l i d s a l t l e n g t h / ,
132+ ) ;
133133 // 15 bytes
134- await expectAsync (
134+ await expect (
135135 Argon2id . execute ( password , fromHex ( "aabbccddeeff001122334455667788" ) , options ) ,
136- ) . toBeRejectedWithError ( / i n v a l i d s a l t l e n g t h / ) ;
136+ ) . rejects . toThrowError ( / i n v a l i d s a l t l e n g t h / ) ;
137137 // 17 bytes
138- await expectAsync (
138+ await expect (
139139 Argon2id . execute ( password , fromHex ( "aabbccddeeff00112233445566778899aa" ) , options ) ,
140- ) . toBeRejectedWithError ( / i n v a l i d s a l t l e n g t h / ) ;
140+ ) . rejects . toThrowError ( / i n v a l i d s a l t l e n g t h / ) ;
141141 // 32 bytes
142- await expectAsync (
142+ await expect (
143143 Argon2id . execute (
144144 password ,
145145 fromHex ( "aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899" ) ,
146146 options ,
147147 ) ,
148- ) . toBeRejectedWithError ( / i n v a l i d s a l t l e n g t h / ) ;
148+ ) . rejects . toThrowError ( / i n v a l i d s a l t l e n g t h / ) ;
149149 } ) ;
150150 } ) ;
151151
@@ -217,13 +217,13 @@ describe("Libsodium", () => {
217217 {
218218 // seed too short
219219 const seed = fromHex ( "43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0" ) ;
220- await expectAsync ( Ed25519 . makeKeypair ( seed ) ) . toBeRejectedWithError ( / k e y o f l e n g t h 3 2 e x p e c t e d / ) ;
220+ await expect ( Ed25519 . makeKeypair ( seed ) ) . rejects . toThrowError ( / k e y o f l e n g t h 3 2 e x p e c t e d / ) ;
221221 }
222222
223223 {
224224 // seed too long
225225 const seed = fromHex ( "43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9aa" ) ;
226- await expectAsync ( Ed25519 . makeKeypair ( seed ) ) . toBeRejectedWithError ( / k e y o f l e n g t h 3 2 e x p e c t e d / ) ;
226+ await expect ( Ed25519 . makeKeypair ( seed ) ) . rejects . toThrowError ( / k e y o f l e n g t h 3 2 e x p e c t e d / ) ;
227227 }
228228 } ) ;
229229
@@ -393,21 +393,21 @@ describe("Libsodium", () => {
393393 {
394394 // empty
395395 const key = fromHex ( "" ) ;
396- await expectAsync ( Xchacha20poly1305Ietf . encrypt ( message , key , nonce ) ) . toBeRejectedWithError (
396+ await expect ( Xchacha20poly1305Ietf . encrypt ( message , key , nonce ) ) . rejects . toThrowError (
397397 / k e y , g o t l e n g t h = 0 / ,
398398 ) ;
399399 }
400400 {
401401 // 31 bytes
402402 const key = fromHex ( "1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916" ) ;
403- await expectAsync ( Xchacha20poly1305Ietf . encrypt ( message , key , nonce ) ) . toBeRejectedWithError (
403+ await expect ( Xchacha20poly1305Ietf . encrypt ( message , key , nonce ) ) . rejects . toThrowError (
404404 / k e y , g o t l e n g t h = 3 1 / ,
405405 ) ;
406406 }
407407 {
408408 // 33 bytes
409409 const key = fromHex ( "1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916d8aa" ) ;
410- await expectAsync ( Xchacha20poly1305Ietf . encrypt ( message , key , nonce ) ) . toBeRejectedWithError (
410+ await expect ( Xchacha20poly1305Ietf . encrypt ( message , key , nonce ) ) . rejects . toThrowError (
411411 / k e y , g o t l e n g t h = 3 3 / ,
412412 ) ;
413413 }
@@ -416,7 +416,7 @@ describe("Libsodium", () => {
416416 const key = fromHex (
417417 "1324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916d81324cdddc4b94e625bbabcac862c9429ba011e2184a1ccad60e7c3f6ff4916d8" ,
418418 ) ;
419- await expectAsync ( Xchacha20poly1305Ietf . encrypt ( message , key , nonce ) ) . toBeRejectedWithError (
419+ await expect ( Xchacha20poly1305Ietf . encrypt ( message , key , nonce ) ) . rejects . toThrowError (
420420 / k e y , g o t l e n g t h = 6 4 / ,
421421 ) ;
422422 }
@@ -438,23 +438,23 @@ describe("Libsodium", () => {
438438 {
439439 // corrupted ciphertext
440440 const corruptedCiphertext = ciphertext . map ( ( x , i ) => ( i === 0 ? x ^ 0x01 : x ) ) ;
441- await expectAsync (
442- Xchacha20poly1305Ietf . decrypt ( corruptedCiphertext , key , nonce ) ,
443- ) . toBeRejectedWithError ( / i n v a l i d t a g / i ) ;
441+ await expect ( Xchacha20poly1305Ietf . decrypt ( corruptedCiphertext , key , nonce ) ) . rejects . toThrowError (
442+ / i n v a l i d t a g / i ,
443+ ) ;
444444 }
445445 {
446446 // corrupted key
447447 const corruptedKey = key . map ( ( x , i ) => ( i === 0 ? x ^ 0x01 : x ) ) ;
448- await expectAsync (
449- Xchacha20poly1305Ietf . decrypt ( ciphertext , corruptedKey , nonce ) ,
450- ) . toBeRejectedWithError ( / i n v a l i d t a g / i ) ;
448+ await expect ( Xchacha20poly1305Ietf . decrypt ( ciphertext , corruptedKey , nonce ) ) . rejects . toThrowError (
449+ / i n v a l i d t a g / i ,
450+ ) ;
451451 }
452452 {
453453 // corrupted nonce
454454 const corruptedNonce = nonce . map ( ( x , i ) => ( i === 0 ? x ^ 0x01 : x ) ) ;
455- await expectAsync (
456- Xchacha20poly1305Ietf . decrypt ( ciphertext , key , corruptedNonce ) ,
457- ) . toBeRejectedWithError ( / i n v a l i d t a g / i ) ;
455+ await expect ( Xchacha20poly1305Ietf . decrypt ( ciphertext , key , corruptedNonce ) ) . rejects . toThrowError (
456+ / i n v a l i d t a g / i ,
457+ ) ;
458458 }
459459 } ) ;
460460
0 commit comments