diff --git a/test/client.test.ts b/test/client.test.ts index 10db54a942..0896d8e587 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -308,6 +308,37 @@ describe('Tests ReactNativeClient', () => { }); }); + describe('normalizes events', () => { + test('handles circular input', async () => { + const mockedSend = jest.fn, [Envelope]>(); + const mockedTransport = (): Transport => ({ + send: mockedSend, + flush: jest.fn().mockResolvedValue(true), + }); + const client = new ReactNativeClient( { + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: mockedTransport, + }); + const circularEvent = { + extra: { + circular: {}, + }, + }; + circularEvent.extra.circular = circularEvent; + + client.captureEvent(circularEvent); + + expect(mockedSend).toBeCalled(); + const actualEvent: Event | undefined = mockedSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload]; + expect(actualEvent?.extra).toEqual({ + circular: { + extra: '[Circular ~]', + }, + }); + }); + }); + describe('clientReports', () => { test('does not send client reports if disabled', () => { const mockTransportSend = jest.fn((_envelope: Envelope) => Promise.resolve());