Skip to content

Commit 19c9c24

Browse files
WIP! Add Expo context integration tests
1 parent 133e929 commit 19c9c24

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

test/integrations/expocontext.test.ts

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { Hub } from '@sentry/core';
2+
import type { Event } from '@sentry/types';
3+
4+
import { ExpoContext } from '../../src/js/integrations/expocontext';
5+
import { getExpoDevice } from '../../src/js/utils/expomodules';
6+
7+
jest.mock('../../src/js/utils/expomodules');
8+
9+
describe('Expo Context Integration', () => {
10+
let integration: ExpoContext;
11+
12+
const mockGetCurrentHub = () =>
13+
({
14+
getIntegration: () => integration,
15+
} as unknown as Hub);
16+
17+
beforeEach(() => {
18+
integration = new ExpoContext();
19+
});
20+
21+
it('does not add device context because expo device module is not available', async () => {
22+
(getExpoDevice as jest.Mock).mockReturnValue(undefined);
23+
const actualEvent = await executeIntegrationFor({});
24+
25+
expect(actualEvent.contexts?.device).toBeUndefined();
26+
});
27+
28+
it('does not add os context because expo device module is not available', async () => {
29+
(getExpoDevice as jest.Mock).mockReturnValue(undefined);
30+
const actualEvent = await executeIntegrationFor({});
31+
32+
expect(actualEvent.contexts?.os).toBeUndefined();
33+
});
34+
35+
it('adds expo device context', async () => {
36+
37+
});
38+
39+
it('adds expo os context', async () => { });
40+
41+
function executeIntegrationFor(mockedEvent: Event): Promise<Event | null> {
42+
return new Promise((resolve, reject) => {
43+
integration.setupOnce(async eventProcessor => {
44+
try {
45+
const processedEvent = await eventProcessor(mockedEvent, {});
46+
resolve(processedEvent);
47+
} catch (e) {
48+
reject(e);
49+
}
50+
}, mockGetCurrentHub);
51+
});
52+
}
53+
});

0 commit comments

Comments
 (0)