Skip to content

Commit

Permalink
chore(client): Add event normalization test (#2635)
Browse files Browse the repository at this point in the history
Co-authored-by: Krisztiaan <[email protected]>
Co-authored-by: Krisztiaan <[email protected]>
  • Loading branch information
3 people authored Nov 22, 2022
1 parent 4174a99 commit 4a6983a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,37 @@ describe('Tests ReactNativeClient', () => {
});
});

describe('normalizes events', () => {
test('handles circular input', async () => {
const mockedSend = jest.fn<PromiseLike<void>, [Envelope]>();
const mockedTransport = (): Transport => ({
send: mockedSend,
flush: jest.fn().mockResolvedValue(true),
});
const client = new ReactNativeClient(<ReactNativeClientOptions> {
...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 = <Event>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());
Expand Down

0 comments on commit 4a6983a

Please sign in to comment.