Skip to content

Commit 2cb9b48

Browse files
committed
chore: fix failing tests
1 parent 0a37c11 commit 2cb9b48

File tree

10 files changed

+2567
-1759
lines changed

10 files changed

+2567
-1759
lines changed

package/jest-setup.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* global require */
2-
import { FlatList, View } from 'react-native';
2+
import rn, { FlatList, View } from 'react-native';
33

44
import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock.js';
5+
import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock';
56

67
import { registerNativeHandlers } from './src/native';
78

@@ -65,3 +66,34 @@ jest.mock('react-native/Libraries/Components/RefreshControl/RefreshControl', ()
6566
jest.mock('@shopify/flash-list', () => ({
6667
FlashList: undefined,
6768
}));
69+
70+
jest.mock('react-native-teleport', () => {
71+
const rn = require('react-native');
72+
return {
73+
Portal: rn.View,
74+
PortalHost: rn.View,
75+
PortalProvider: rn.View,
76+
usePortal: jest.fn().mockReturnValue({ removePortal: jest.fn() }),
77+
};
78+
});
79+
80+
jest.mock('react-native-teleport', () => {
81+
const rn = require('react-native');
82+
return {
83+
Portal: rn.View,
84+
PortalHost: rn.View,
85+
PortalProvider: rn.View,
86+
usePortal: jest.fn().mockReturnValue({ removePortal: jest.fn() }),
87+
};
88+
});
89+
90+
jest.mock('react-native-safe-area-context', () => mockSafeAreaContext);
91+
92+
jest.mock('./src/components/Message/utils/measureInWindow', () => ({
93+
measureInWindow: jest.fn(async () => ({
94+
x: 10,
95+
y: 100,
96+
w: 250,
97+
h: 60,
98+
})),
99+
}));

package/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
"react-native-keyboard-controller": ">=1.20.2",
9595
"react-native-reanimated": ">=3.16.0",
9696
"react-native-safe-area-context": ">=5.4.1",
97-
"react-native-svg": ">=15.8.0"
97+
"react-native-svg": ">=15.8.0",
98+
"react-native-teleport": ">=0.5.4"
9899
},
99100
"peerDependenciesMeta": {
100101
"@op-engineering/op-sqlite": {
@@ -162,7 +163,7 @@
162163
"react-native-reanimated": "3.18.0",
163164
"react-native-safe-area-context": "^5.6.1",
164165
"react-native-svg": "15.12.0",
165-
"react-native-teleport": "^0.5.3",
166+
"react-native-teleport": "^0.5.4",
166167
"react-test-renderer": "19.1.0",
167168
"rimraf": "^6.0.1",
168169
"typescript": "5.8.3",

package/src/components/Channel/__tests__/ownCapabilities.test.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import { FlatList } from 'react-native';
33

4+
import { SafeAreaProvider } from 'react-native-safe-area-context';
5+
46
import { act, fireEvent, render, waitFor } from '@testing-library/react-native';
57

68
import { OverlayProvider } from '../../../contexts/overlayContext/OverlayProvider';
@@ -47,14 +49,16 @@ describe('Own capabilities', () => {
4749
});
4850

4951
const getComponent = (props = {}) => (
50-
<OverlayProvider>
51-
<Chat client={chatClient}>
52-
<Channel channel={channel} {...props}>
53-
<MessageList FlatList={FlatList} />
54-
<MessageInput />
55-
</Channel>
56-
</Chat>
57-
</OverlayProvider>
52+
<SafeAreaProvider>
53+
<OverlayProvider>
54+
<Chat client={chatClient}>
55+
<Channel channel={channel} {...props}>
56+
<MessageList FlatList={FlatList} />
57+
<MessageInput />
58+
</Channel>
59+
</Chat>
60+
</OverlayProvider>
61+
</SafeAreaProvider>
5862
);
5963

6064
const generateChannelWithCapabilities = async (capabilities = []) => {

package/src/components/Message/MessageSimple/__tests__/Message.test.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22

3+
import { SafeAreaProvider } from 'react-native-safe-area-context';
4+
35
import { cleanup, fireEvent, render, waitFor } from '@testing-library/react-native';
46

57
import { OverlayProvider } from '../../../../contexts/overlayContext/OverlayProvider';
@@ -37,15 +39,16 @@ describe('Message', () => {
3739

3840
renderMessage = (options) =>
3941
render(
40-
<OverlayProvider>
41-
<Chat client={chatClient}>
42-
<Channel channel={channel}>
43-
<Message groupStyles={['bottom']} {...options} />
44-
<MessageInput />
45-
</Channel>
46-
</Chat>
47-
,
48-
</OverlayProvider>,
42+
<SafeAreaProvider>
43+
<OverlayProvider>
44+
<Chat client={chatClient}>
45+
<Channel channel={channel}>
46+
<Message groupStyles={['bottom']} {...options} />
47+
<MessageInput />
48+
</Channel>
49+
</Chat>
50+
</OverlayProvider>
51+
</SafeAreaProvider>,
4952
);
5053
});
5154

0 commit comments

Comments
 (0)