@@ -255,19 +255,25 @@ describe('RoktManager', () => {
255255 expect ( emptyStringHash ) . toBe ( 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' ) ;
256256 } ) ;
257257
258- it ( 'should reject when value is null' , async ( ) => {
259- await expect ( roktManager . hashSha256 ( null ) ) . rejects . toThrow ( 'Value cannot be null or undefined' ) ;
258+ it ( 'should return null and log warning when value is null' , async ( ) => {
259+ const result = await roktManager . hashSha256 ( null ) ;
260+
261+ expect ( result ) . toBeNull ( ) ;
262+ expect ( mockMPInstance . Logger . warning ) . toHaveBeenCalledWith ( 'hashSha256 received null as input' ) ;
260263 } ) ;
261264
262- it ( 'should reject when value is undefined' , async ( ) => {
263- await expect ( roktManager . hashSha256 ( undefined ) ) . rejects . toThrow ( 'Value cannot be null or undefined' ) ;
265+ it ( 'should return undefined and log warning when value is undefined' , async ( ) => {
266+ const result = await roktManager . hashSha256 ( undefined ) ;
267+
268+ expect ( result ) . toBeUndefined ( ) ;
269+ expect ( mockMPInstance . Logger . warning ) . toHaveBeenCalledWith ( 'hashSha256 received undefined as input' ) ;
264270 } ) ;
265271
266272 it ( 'should log error when hashing fails' , async ( ) => {
267273 shaSpy . mockRejectedValue ( new Error ( 'Hash failed' ) ) ;
268274
269275 await expect ( roktManager . hashSha256 ( '[email protected] ' ) ) . rejects . toThrow ( ) ; 270- expect ( mockMPInstance . Logger . error ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Failed hashSha256 ' ) ) ;
276+ expect ( mockMPInstance . Logger . error ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Failed to hash attribute ' ) ) ;
271277 } ) ;
272278
273279 it ( 'should hash firstName to known SHA-256 value' , async ( ) => {
0 commit comments