Skip to content

Commit ad0f66d

Browse files
committed
return undefined instead of throwing when hashSha256 fails
1 parent d1b81d0 commit ad0f66d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

test/jest/roktManager.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,15 @@ describe('RoktManager', () => {
333333
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received undefined as input');
334334
});
335335

336-
it('should log error when hashing fails', async () => {
336+
it('should return undefined and log error when hashing fails', async () => {
337337
shaSpy.mockRejectedValue(new Error('Hash failed'));
338338

339-
await expect(roktManager.hashSha256('test@example.com')).rejects.toThrow();
340-
expect(mockMPInstance.Logger.error).toHaveBeenCalledWith(expect.stringContaining('Failed to hash attribute'));
339+
const result = await roktManager.hashSha256('test@example.com');
340+
341+
expect(result).toBeUndefined();
342+
expect(mockMPInstance.Logger.error).toHaveBeenCalledWith(
343+
expect.stringContaining('Failed to hash "test@example.com" and returning undefined, selectPlacements will continue')
344+
);
341345
});
342346

343347
it('should hash firstName to known SHA-256 value', async () => {

0 commit comments

Comments
 (0)