Skip to content

Commit 16f7a8a

Browse files
author
tamilr0727-ux
committed
test(utils): check boundary robustness of JSON response serializer (Variation 3)
1 parent e6b5723 commit 16f7a8a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

utils/tracking.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,19 @@ describe('trackUser', () => {
176176
expect(fetchMock).not.toHaveBeenCalled();
177177
});
178178
});
179+
180+
describe('JSON response serializer — boundary robustness (Variation 3)', () => {
181+
it('verifies the utility catches the exception and reports format errors when passed non-serializable JSON payloads', () => {
182+
// Arrange: Create a non-serializable payload using a circular reference
183+
const circularStructure: Record<string, unknown> = {};
184+
circularStructure['self'] = circularStructure;
185+
186+
// Provide a trim method that returns the circular structure to trigger the serialization error
187+
const nonSerializablePayload = {
188+
trim: () => circularStructure,
189+
};
190+
191+
// Act & Assert: Invoke the utility with the target inputs and verify it handles it gracefully
192+
expect(() => trackUser(nonSerializablePayload as unknown as string)).not.toThrow();
193+
});
194+
});

0 commit comments

Comments
 (0)