Skip to content

Commit 5e9c8cd

Browse files
committed
fix failing roktManager logger tests
1 parent 8456edd commit 5e9c8cd

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

test/jest/roktManager.spec.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ describe('RoktManager', () => {
167167

168168
expect(result).toEqual({});
169169
expect(mockMPInstance.Logger.error).toHaveBeenCalledWith(
170-
expect.stringContaining('Failed to hashAttributes, returning an empty object: Hashing failed')
170+
expect.stringContaining('Failed to hashAttributes, returning an empty object: Hashing failed'),
171+
'ROKT_HASHING_FAILED'
171172
);
172173
});
173174
});
@@ -217,14 +218,14 @@ describe('RoktManager', () => {
217218
const result = await roktManager.hashSha256(null);
218219

219220
expect(result).toBeNull();
220-
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received null/undefined as input');
221+
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received null/undefined as input', 'ROKT_HASHING_FAILED');
221222
});
222223

223224
it('should return undefined and log warning when value is undefined', async () => {
224225
const result = await roktManager.hashSha256(undefined);
225226

226227
expect(result).toBeUndefined();
227-
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received null/undefined as input');
228+
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received null/undefined as input', 'ROKT_HASHING_FAILED');
228229
});
229230

230231
it('should return undefined and log error when hashing fails', async () => {
@@ -234,7 +235,8 @@ describe('RoktManager', () => {
234235

235236
expect(result).toBeUndefined();
236237
expect(mockMPInstance.Logger.error).toHaveBeenCalledWith(
237-
expect.stringContaining('Failed to hashSha256, returning undefined: Hash failed')
238+
expect.stringContaining('Failed to hashSha256, returning undefined: Hash failed'),
239+
'ROKT_HASHING_FAILED'
238240
);
239241
});
240242

@@ -574,7 +576,8 @@ describe('RoktManager', () => {
574576
roktManager.attachKit(kit);
575577

576578
expect(mockLogger.error).toHaveBeenCalledWith(
577-
expect.stringContaining('RoktManager: Error in onReadyCallback')
579+
expect.stringContaining('RoktManager: Error in onReadyCallback'),
580+
'ROKT_IDENTITY_FALLBACK_FAILED'
578581
);
579582
});
580583
});
@@ -884,7 +887,8 @@ describe('RoktManager', () => {
884887

885888
// Verify error was logged for non-existent method
886889
expect(mockMPInstance.Logger.error).toHaveBeenCalledWith(
887-
'RoktManager: Method nonExistentMethod not found'
890+
'RoktManager: Method nonExistentMethod not found',
891+
'ROKT_QUEUE_PROCESSING_FAILED'
888892
);
889893

890894
// Verify message was removed from queue even though method didn't exist
@@ -1536,7 +1540,8 @@ describe('RoktManager', () => {
15361540
}
15371541
}, expect.any(Function));
15381542
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith(
1539-
'Email mismatch detected. Current email differs from email passed to selectPlacements call. Proceeding to call identify with email from selectPlacements call. Please verify your implementation.'
1543+
'Email mismatch detected. Current email differs from email passed to selectPlacements call. Proceeding to call identify with email from selectPlacements call. Please verify your implementation.',
1544+
'ROKT_IDENTITY_MISMATCH'
15401545
);
15411546
});
15421547

@@ -1723,7 +1728,8 @@ describe('RoktManager', () => {
17231728
}
17241729
}, expect.any(Function));
17251730
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith(
1726-
"emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation."
1731+
"emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.",
1732+
'ROKT_IDENTITY_MISMATCH'
17271733
);
17281734
});
17291735

@@ -1813,7 +1819,8 @@ describe('RoktManager', () => {
18131819
}
18141820
}, expect.any(Function));
18151821
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith(
1816-
"emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation."
1822+
"emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.",
1823+
'ROKT_IDENTITY_MISMATCH'
18171824
);
18181825
});
18191826

@@ -2196,7 +2203,8 @@ describe('RoktManager', () => {
21962203

21972204
// Verify error was logged
21982205
expect(mockMPInstance.Logger.error).toHaveBeenCalledWith(
2199-
'Failed to identify user with new email: ' + JSON.stringify(mockError)
2206+
'Failed to identify user with new email: ' + JSON.stringify(mockError),
2207+
'IDENTITY_REQUEST'
22002208
);
22012209

22022210
// Verify selectPlacements was still called

0 commit comments

Comments
 (0)