Skip to content

Commit

Permalink
Fix JS tests JS keeps breadcrumbs on android
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Jul 13, 2023
1 parent 65211d0 commit 74b5094
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ describe('Tests Native Wrapper', () => {
{ store: false },
);
});
test('Clears breadcrumbs on Android if mechanism.handled is true', async () => {
test('Keeps breadcrumbs on Android if mechanism.handled is true', async () => {
NATIVE.platform = 'android';

const event: Event = {
Expand Down Expand Up @@ -318,12 +318,12 @@ describe('Tests Native Wrapper', () => {
utf8ToBytes(
'{"event_id":"event0","sent_at":"123"}\n' +
'{"type":"event","content_type":"application/json","length":104}\n' +
'{"event_id":"event0","exception":{"values":[{"mechanism":{"handled":true,"type":""}}]},"breadcrumbs":[]}\n',
'{"event_id":"event0","exception":{"values":[{"mechanism":{"handled":true,"type":""}}]},"breadcrumbs":[{"message":"crumb!"}]}\n',
),
{ store: false },
);
});
test('Clears breadcrumbs on Android if there is no exception', async () => {
test('Keeps breadcrumbs on Android if there is no exception', async () => {
NATIVE.platform = 'android';

const event: Event = {
Expand All @@ -345,12 +345,12 @@ describe('Tests Native Wrapper', () => {
utf8ToBytes(
'{"event_id":"event0","sent_at":"123"}\n' +
'{"type":"event","content_type":"application/json","length":38}\n' +
'{"event_id":"event0","breadcrumbs":[]}\n',
'{"event_id":"event0","breadcrumbs":[{"message":"crumb!"}]}\n',
),
{ store: false },
);
});
test('Does not clear breadcrumbs on Android if mechanism.handled is false', async () => {
test('Keeps breadcrumbs on Android if mechanism.handled is false', async () => {
NATIVE.platform = 'android';

const event: Event = {
Expand Down Expand Up @@ -411,12 +411,16 @@ describe('Tests Native Wrapper', () => {

expect(RNSentry.fetchNativeDeviceContexts).toBeCalled();
});
test('returns empty object on android', async () => {
test('returns context object from native module on android', async () => {
NATIVE.platform = 'android';

await expect(NATIVE.fetchNativeDeviceContexts()).resolves.toMatchObject({});
await expect(NATIVE.fetchNativeDeviceContexts()).resolves.toMatchObject({
someContext: {
someValue: 0,
},
});

expect(RNSentry.fetchNativeDeviceContexts).not.toBeCalled();
expect(RNSentry.fetchNativeDeviceContexts).toBeCalled();
});
});

Expand Down

0 comments on commit 74b5094

Please sign in to comment.