@@ -55,10 +55,9 @@ describe('Encryption Utilities', () => {
5555 const password = testData . password ;
5656 const salt = 'testsalt12345678901234567890123456789012' ;
5757
58- const result = encrypt ( data , password , salt ) ;
58+ const result = encrypt ( JSON . stringify ( data ) , password , salt ) ;
5959
6060 expect ( typeof result ) . toBe ( 'string' ) ;
61- expect ( result ) . toHaveLength ( 44 ) ; // AES encrypted strings are typically 44 chars
6261 } ) ;
6362
6463 it ( 'should produce different results for different data' , ( ) => {
@@ -99,10 +98,11 @@ describe('Encryption Utilities', () => {
9998 const password = testData . password ;
10099 const salt = generateSalt ( ) ;
101100
102- const encrypted = encrypt ( originalData , password , salt ) ;
101+ const actual = JSON . stringify ( originalData ) ;
102+ const encrypted = encrypt ( actual , password , salt ) ;
103103 const decrypted = decrypt ( encrypted , password , salt ) ;
104104
105- expect ( decrypted ) . toEqual ( originalData ) ;
105+ expect ( decrypted ) . toEqual ( actual ) ;
106106 } ) ;
107107
108108 it ( 'should throw error for invalid encrypted data' , ( ) => {
@@ -214,10 +214,11 @@ describe('Encryption Utilities', () => {
214214 const password = testData . password ;
215215 const salt = generateSalt ( ) ;
216216
217- const encrypted = encrypt ( complexData , password , salt ) ;
217+ const actual = JSON . stringify ( complexData ) ;
218+ const encrypted = encrypt ( actual , password , salt ) ;
218219 const decrypted = decrypt ( encrypted , password , salt ) ;
219220
220- expect ( decrypted ) . toEqual ( complexData ) ;
221+ expect ( decrypted ) . toEqual ( actual ) ;
221222 } ) ;
222223
223224 it ( 'should maintain data integrity through encrypt/decrypt cycle' , ( ) => {
@@ -238,10 +239,11 @@ describe('Encryption Utilities', () => {
238239 const salt = generateSalt ( ) ;
239240
240241 testCases . forEach ( ( data ) => {
241- const encrypted = encrypt ( data , password , salt ) ;
242+ const actual = typeof data === 'string' ? data : JSON . stringify ( data ) ;
243+ const encrypted = encrypt ( actual , password , salt ) ;
242244 const decrypted = decrypt ( encrypted , password , salt ) ;
243245
244- expect ( decrypted ) . toEqual ( data ) ;
246+ expect ( decrypted ) . toEqual ( actual ) ;
245247 } ) ;
246248 } ) ;
247249 } ) ;
0 commit comments