react-native-gifted-chat 2.8.2-alpha.0 → 2.8.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -31
- package/package.json +28 -30
- package/src/Actions.tsx +1 -1
- package/src/Avatar.tsx +1 -1
- package/src/Bubble/index.tsx +24 -20
- package/src/Bubble/types.ts +7 -6
- package/src/Composer.tsx +19 -26
- package/src/Constant.ts +0 -1
- package/src/Day/index.tsx +3 -3
- package/src/GiftedAvatar.tsx +31 -38
- package/src/GiftedChat/index.tsx +59 -106
- package/src/GiftedChat/styles.ts +3 -0
- package/src/GiftedChat/types.ts +17 -67
- package/src/InputToolbar.tsx +27 -10
- package/src/LoadEarlier.tsx +22 -20
- package/src/Message/index.tsx +4 -18
- package/src/Message/types.ts +2 -2
- package/src/MessageAudio.tsx +19 -7
- package/src/MessageContainer/components/DayAnimated/index.tsx +16 -11
- package/src/MessageContainer/components/Item/index.tsx +10 -4
- package/src/MessageContainer/components/Item/types.ts +1 -1
- package/src/MessageContainer/index.tsx +57 -38
- package/src/MessageContainer/types.ts +32 -7
- package/src/MessageImage.tsx +132 -18
- package/src/MessageText.tsx +24 -64
- package/src/MessageVideo.tsx +19 -7
- package/src/QuickReplies.tsx +19 -12
- package/src/Send.tsx +10 -5
- package/src/SystemMessage.tsx +10 -3
- package/src/Time.tsx +10 -3
- package/src/TypingIndicator/index.tsx +4 -3
- package/src/TypingIndicator/types.ts +3 -0
- package/src/__tests__/Actions.test.tsx +3 -4
- package/src/__tests__/Avatar.test.tsx +5 -6
- package/src/__tests__/Bubble.test.tsx +14 -19
- package/src/__tests__/Composer.test.tsx +3 -4
- package/src/__tests__/Day.test.tsx +5 -8
- package/src/__tests__/DayAnimated.test.tsx +12 -14
- package/src/__tests__/GiftedAvatar.test.tsx +3 -8
- package/src/__tests__/GiftedChat.test.tsx +34 -43
- package/src/__tests__/InputToolbar.test.tsx +3 -4
- package/src/__tests__/LoadEarlier.test.tsx +3 -4
- package/src/__tests__/Message.test.tsx +51 -58
- package/src/__tests__/MessageContainer.test.tsx +39 -5
- package/src/__tests__/MessageImage.test.tsx +12 -15
- package/src/__tests__/MessageText.test.tsx +7 -4
- package/src/__tests__/Send.test.tsx +7 -8
- package/src/__tests__/SystemMessage.test.tsx +12 -15
- package/src/__tests__/Time.test.tsx +5 -8
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +39 -7
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +48 -50
- package/src/__tests__/__snapshots__/Composer.test.tsx.snap +1 -2
- package/src/__tests__/__snapshots__/Constant.test.tsx.snap +0 -1
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +20 -22
- package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +2 -2
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +37 -6
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +146 -150
- package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +32 -11
- package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +12 -8
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +72 -10
- package/src/components/TouchableOpacity.tsx +45 -0
- package/src/reanimatedCompat.ts +27 -0
- package/src/types.ts +4 -2
- package/src/utils.ts +2 -2
- package/lib/Actions.d.ts +0 -14
- package/lib/Actions.js +0 -57
- package/lib/Actions.js.map +0 -1
- package/lib/Avatar.d.ts +0 -18
- package/lib/Avatar.js +0 -93
- package/lib/Avatar.js.map +0 -1
- package/lib/Bubble/index.d.ts +0 -6
- package/lib/Bubble/index.js +0 -242
- package/lib/Bubble/index.js.map +0 -1
- package/lib/Bubble/styles.d.ts +0 -69
- package/lib/Bubble/styles.js +0 -72
- package/lib/Bubble/styles.js.map +0 -1
- package/lib/Bubble/types.d.ts +0 -47
- package/lib/Bubble/types.js +0 -2
- package/lib/Bubble/types.js.map +0 -1
- package/lib/Color.d.ts +0 -18
- package/lib/Color.js +0 -18
- package/lib/Color.js.map +0 -1
- package/lib/Composer.d.ts +0 -20
- package/lib/Composer.js +0 -60
- package/lib/Composer.js.map +0 -1
- package/lib/Constant.d.ts +0 -10
- package/lib/Constant.js +0 -17
- package/lib/Constant.js.map +0 -1
- package/lib/Day/index.d.ts +0 -4
- package/lib/Day/index.js +0 -39
- package/lib/Day/index.js.map +0 -1
- package/lib/Day/styles.d.ts +0 -20
- package/lib/Day/styles.js +0 -22
- package/lib/Day/styles.js.map +0 -1
- package/lib/Day/types.d.ts +0 -9
- package/lib/Day/types.js +0 -2
- package/lib/Day/types.js.map +0 -1
- package/lib/GiftedAvatar.d.ts +0 -11
- package/lib/GiftedAvatar.js +0 -104
- package/lib/GiftedAvatar.js.map +0 -1
- package/lib/GiftedChat/index.d.ts +0 -26
- package/lib/GiftedChat/index.js +0 -317
- package/lib/GiftedChat/index.js.map +0 -1
- package/lib/GiftedChat/styles.d.ts +0 -6
- package/lib/GiftedChat/styles.js +0 -7
- package/lib/GiftedChat/styles.js.map +0 -1
- package/lib/GiftedChat/types.d.ts +0 -112
- package/lib/GiftedChat/types.js +0 -2
- package/lib/GiftedChat/types.js.map +0 -1
- package/lib/GiftedChatContext.d.ts +0 -9
- package/lib/GiftedChatContext.js +0 -9
- package/lib/GiftedChatContext.js.map +0 -1
- package/lib/InputToolbar.d.ts +0 -23
- package/lib/InputToolbar.js +0 -56
- package/lib/InputToolbar.js.map +0 -1
- package/lib/LoadEarlier.d.ts +0 -14
- package/lib/LoadEarlier.js +0 -45
- package/lib/LoadEarlier.js.map +0 -1
- package/lib/Message/index.d.ts +0 -6
- package/lib/Message/index.js +0 -80
- package/lib/Message/index.js.map +0 -1
- package/lib/Message/styles.d.ts +0 -21
- package/lib/Message/styles.js +0 -22
- package/lib/Message/styles.js.map +0 -1
- package/lib/Message/types.d.ts +0 -22
- package/lib/Message/types.js +0 -2
- package/lib/Message/types.js.map +0 -1
- package/lib/MessageAudio.d.ts +0 -2
- package/lib/MessageAudio.js +0 -14
- package/lib/MessageAudio.js.map +0 -1
- package/lib/MessageContainer/components/DayAnimated/index.d.ts +0 -5
- package/lib/MessageContainer/components/DayAnimated/index.js +0 -85
- package/lib/MessageContainer/components/DayAnimated/index.js.map +0 -1
- package/lib/MessageContainer/components/DayAnimated/styles.d.ts +0 -11
- package/lib/MessageContainer/components/DayAnimated/styles.js +0 -12
- package/lib/MessageContainer/components/DayAnimated/styles.js.map +0 -1
- package/lib/MessageContainer/components/DayAnimated/types.d.ts +0 -17
- package/lib/MessageContainer/components/DayAnimated/types.js +0 -2
- package/lib/MessageContainer/components/DayAnimated/types.js.map +0 -1
- package/lib/MessageContainer/components/Item/index.d.ts +0 -23
- package/lib/MessageContainer/components/Item/index.js +0 -88
- package/lib/MessageContainer/components/Item/index.js.map +0 -1
- package/lib/MessageContainer/components/Item/types.d.ts +0 -17
- package/lib/MessageContainer/components/Item/types.js +0 -2
- package/lib/MessageContainer/components/Item/types.js.map +0 -1
- package/lib/MessageContainer/index.d.ts +0 -6
- package/lib/MessageContainer/index.js +0 -235
- package/lib/MessageContainer/index.js.map +0 -1
- package/lib/MessageContainer/styles.d.ts +0 -35
- package/lib/MessageContainer/styles.js +0 -32
- package/lib/MessageContainer/styles.js.map +0 -1
- package/lib/MessageContainer/types.d.ts +0 -51
- package/lib/MessageContainer/types.js +0 -2
- package/lib/MessageContainer/types.js.map +0 -1
- package/lib/MessageImage.d.ts +0 -13
- package/lib/MessageImage.js +0 -30
- package/lib/MessageImage.js.map +0 -1
- package/lib/MessageText.d.ts +0 -19
- package/lib/MessageText.js +0 -69
- package/lib/MessageText.js.map +0 -1
- package/lib/MessageVideo.d.ts +0 -2
- package/lib/MessageVideo.js +0 -14
- package/lib/MessageVideo.js.map +0 -1
- package/lib/QuickReplies.d.ts +0 -15
- package/lib/QuickReplies.js +0 -101
- package/lib/QuickReplies.js.map +0 -1
- package/lib/Send.d.ts +0 -15
- package/lib/Send.js +0 -34
- package/lib/Send.js.map +0 -1
- package/lib/SystemMessage.d.ts +0 -11
- package/lib/SystemMessage.js +0 -27
- package/lib/SystemMessage.js.map +0 -1
- package/lib/Time.d.ts +0 -11
- package/lib/Time.js +0 -56
- package/lib/Time.js.map +0 -1
- package/lib/TypingIndicator/index.d.ts +0 -5
- package/lib/TypingIndicator/index.js +0 -94
- package/lib/TypingIndicator/index.js.map +0 -1
- package/lib/TypingIndicator/styles.d.ts +0 -20
- package/lib/TypingIndicator/styles.js +0 -22
- package/lib/TypingIndicator/styles.js.map +0 -1
- package/lib/TypingIndicator/types.d.ts +0 -3
- package/lib/TypingIndicator/types.js +0 -2
- package/lib/TypingIndicator/types.js.map +0 -1
- package/lib/hooks/useUpdateLayoutEffect.d.ts +0 -8
- package/lib/hooks/useUpdateLayoutEffect.js +0 -17
- package/lib/hooks/useUpdateLayoutEffect.js.map +0 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -5
- package/lib/index.js.map +0 -1
- package/lib/logging.d.ts +0 -2
- package/lib/logging.js +0 -5
- package/lib/logging.js.map +0 -1
- package/lib/styles.d.ts +0 -10
- package/lib/styles.js +0 -11
- package/lib/styles.js.map +0 -1
- package/lib/types.d.ts +0 -67
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/lib/utils.d.ts +0 -5
- package/lib/utils.js +0 -83
- package/lib/utils.js.map +0 -1
- package/src/__tests__/__snapshots__/MessageContainer.test.tsx.snap +0 -108
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { Day } from '../GiftedChat'
|
|
6
5
|
import { DEFAULT_TEST_MESSAGE } from './data'
|
|
7
6
|
|
|
8
7
|
describe('Day', () => {
|
|
9
8
|
it('should not render <Day /> and compare with snapshot', () => {
|
|
10
|
-
const
|
|
11
|
-
const tree = component.toJSON()
|
|
9
|
+
const { toJSON } = render(<Day />)
|
|
12
10
|
|
|
13
|
-
expect(
|
|
11
|
+
expect(toJSON()).toMatchSnapshot()
|
|
14
12
|
})
|
|
15
13
|
|
|
16
14
|
it('should render <Day /> and compare with snapshot', () => {
|
|
17
|
-
const
|
|
15
|
+
const { toJSON } = render(
|
|
18
16
|
<Day currentMessage={DEFAULT_TEST_MESSAGE} />
|
|
19
17
|
)
|
|
20
|
-
|
|
21
|
-
expect(tree).toMatchSnapshot()
|
|
18
|
+
expect(toJSON()).toMatchSnapshot()
|
|
22
19
|
})
|
|
23
20
|
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { View, Text } from 'react-native'
|
|
3
|
+
import { render } from '@testing-library/react-native'
|
|
5
4
|
import { DayProps } from '../Day'
|
|
5
|
+
import DayAnimated from '../MessageContainer/components/DayAnimated'
|
|
6
6
|
|
|
7
7
|
const mockDaysPositions = { value: {} }
|
|
8
8
|
const mockScrolledY = { value: 0 }
|
|
@@ -17,7 +17,7 @@ const mockMessage = {
|
|
|
17
17
|
|
|
18
18
|
describe('DayAnimated', () => {
|
|
19
19
|
it('should render DayAnimated with default Day component', () => {
|
|
20
|
-
const
|
|
20
|
+
const { toJSON } = render(
|
|
21
21
|
<DayAnimated
|
|
22
22
|
scrolledY={mockScrolledY}
|
|
23
23
|
daysPositions={mockDaysPositions}
|
|
@@ -26,14 +26,17 @@ describe('DayAnimated', () => {
|
|
|
26
26
|
isLoadingEarlier={false}
|
|
27
27
|
/>
|
|
28
28
|
)
|
|
29
|
-
|
|
30
|
-
expect(tree).toMatchSnapshot()
|
|
29
|
+
expect(toJSON()).toMatchSnapshot()
|
|
31
30
|
})
|
|
32
31
|
|
|
33
32
|
it('should use custom renderDay when provided', () => {
|
|
34
|
-
const customRenderDay = jest.fn((props: DayProps) =>
|
|
33
|
+
const customRenderDay = jest.fn((props: DayProps) => (
|
|
34
|
+
<View testID='custom-day'>
|
|
35
|
+
<Text>Custom Day: {props.createdAt}</Text>
|
|
36
|
+
</View>
|
|
37
|
+
))
|
|
35
38
|
|
|
36
|
-
const
|
|
39
|
+
const { toJSON } = render(
|
|
37
40
|
<DayAnimated
|
|
38
41
|
scrolledY={mockScrolledY}
|
|
39
42
|
daysPositions={mockDaysPositions}
|
|
@@ -44,11 +47,6 @@ describe('DayAnimated', () => {
|
|
|
44
47
|
/>
|
|
45
48
|
)
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
component.getInstance()
|
|
49
|
-
|
|
50
|
-
// The custom renderDay function should be available in the component
|
|
51
|
-
const tree = component.toJSON()
|
|
52
|
-
expect(tree).toMatchSnapshot()
|
|
50
|
+
expect(toJSON()).toMatchSnapshot()
|
|
53
51
|
})
|
|
54
52
|
})
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { GiftedAvatar } from '../GiftedChat'
|
|
6
5
|
|
|
7
6
|
it('should render <GiftedAvatar /> and compare with snapshot', () => {
|
|
8
|
-
|
|
7
|
+
const { toJSON } = render(<GiftedAvatar />)
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
tree = renderer.create(<GiftedAvatar />)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
expect(tree.toJSON()).toMatchSnapshot()
|
|
9
|
+
expect(toJSON()).toMatchSnapshot()
|
|
15
10
|
})
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
|
-
import { GiftedChat } from '../GiftedChat'
|
|
6
4
|
import { useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller'
|
|
5
|
+
import { GiftedChat } from '../GiftedChat'
|
|
7
6
|
|
|
8
7
|
const messages = [
|
|
9
8
|
{
|
|
@@ -18,50 +17,42 @@ const messages = [
|
|
|
18
17
|
]
|
|
19
18
|
|
|
20
19
|
it('should render <GiftedChat/> and compare with snapshot', () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
height: {
|
|
26
|
-
value: 0,
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
tree = renderer.create(
|
|
31
|
-
<GiftedChat
|
|
32
|
-
messages={messages}
|
|
33
|
-
onSend={() => {}}
|
|
34
|
-
user={{
|
|
35
|
-
_id: 1,
|
|
36
|
-
}}
|
|
37
|
-
/>
|
|
38
|
-
)
|
|
20
|
+
(useReanimatedKeyboardAnimation as jest.Mock).mockReturnValue({
|
|
21
|
+
height: {
|
|
22
|
+
value: 0,
|
|
23
|
+
},
|
|
39
24
|
})
|
|
40
25
|
|
|
41
|
-
|
|
26
|
+
const { toJSON } = render(
|
|
27
|
+
<GiftedChat
|
|
28
|
+
messages={messages}
|
|
29
|
+
onSend={() => {}}
|
|
30
|
+
user={{
|
|
31
|
+
_id: 1,
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
expect(toJSON()).toMatchSnapshot()
|
|
42
37
|
})
|
|
43
38
|
|
|
44
|
-
it('should render <GiftedChat/> with
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
height: {
|
|
50
|
-
value: 0,
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
tree = renderer.create(
|
|
55
|
-
<GiftedChat
|
|
56
|
-
messages={messages}
|
|
57
|
-
onSend={() => {}}
|
|
58
|
-
user={{
|
|
59
|
-
_id: 1,
|
|
60
|
-
}}
|
|
61
|
-
disableKeyboardController={true}
|
|
62
|
-
/>
|
|
63
|
-
)
|
|
39
|
+
it('should render <GiftedChat/> with isKeyboardInternallyHandled=false', () => {
|
|
40
|
+
(useReanimatedKeyboardAnimation as jest.Mock).mockReturnValue({
|
|
41
|
+
height: {
|
|
42
|
+
value: 0,
|
|
43
|
+
},
|
|
64
44
|
})
|
|
65
45
|
|
|
66
|
-
|
|
46
|
+
const { toJSON } = render(
|
|
47
|
+
<GiftedChat
|
|
48
|
+
messages={messages}
|
|
49
|
+
onSend={() => {}}
|
|
50
|
+
user={{
|
|
51
|
+
_id: 1,
|
|
52
|
+
}}
|
|
53
|
+
isKeyboardInternallyHandled={false}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
expect(toJSON()).toMatchSnapshot()
|
|
67
58
|
})
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { InputToolbar } from '../GiftedChat'
|
|
6
5
|
|
|
7
6
|
it('should render <InputToolbar /> and compare with snapshot', () => {
|
|
8
|
-
const
|
|
7
|
+
const { toJSON } = render(<InputToolbar />)
|
|
9
8
|
|
|
10
|
-
expect(
|
|
9
|
+
expect(toJSON()).toMatchSnapshot()
|
|
11
10
|
})
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { LoadEarlier } from '../GiftedChat'
|
|
6
5
|
|
|
7
6
|
it('should render <LoadEarlier /> and compare with snapshot', () => {
|
|
8
|
-
const
|
|
7
|
+
const { toJSON } = render(<LoadEarlier />)
|
|
9
8
|
|
|
10
|
-
expect(
|
|
9
|
+
expect(toJSON()).toMatchSnapshot()
|
|
11
10
|
})
|
|
@@ -1,80 +1,73 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { Message } from '../GiftedChat'
|
|
6
5
|
|
|
7
6
|
describe('Message component', () => {
|
|
8
7
|
it('should render <Message /> and compare with snapshot', () => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
23
|
-
.toJSON()
|
|
8
|
+
const { toJSON } = render(
|
|
9
|
+
<Message
|
|
10
|
+
key='123'
|
|
11
|
+
user={{ _id: 1 }}
|
|
12
|
+
currentMessage={{
|
|
13
|
+
_id: 1,
|
|
14
|
+
text: 'test',
|
|
15
|
+
createdAt: 1554744013721,
|
|
16
|
+
user: { _id: 1 },
|
|
17
|
+
}}
|
|
18
|
+
position='left'
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
24
21
|
|
|
25
|
-
expect(
|
|
22
|
+
expect(toJSON()).toMatchSnapshot()
|
|
26
23
|
})
|
|
27
24
|
|
|
28
25
|
it('should NOT render <Message />', () => {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const { toJSON } = render(
|
|
27
|
+
<Message key='123' user={{ _id: 1 }} currentMessage={null} position='left' />
|
|
28
|
+
)
|
|
32
29
|
|
|
33
|
-
expect(
|
|
30
|
+
expect(toJSON()).toMatchSnapshot()
|
|
34
31
|
})
|
|
35
32
|
|
|
36
33
|
it('should render <Message /> with Avatar', () => {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
.toJSON()
|
|
34
|
+
const { toJSON } = render(
|
|
35
|
+
<Message
|
|
36
|
+
key='123'
|
|
37
|
+
user={{ _id: 1 }}
|
|
38
|
+
currentMessage={{
|
|
39
|
+
_id: 1,
|
|
40
|
+
text: 'test',
|
|
41
|
+
createdAt: 1554744013721,
|
|
42
|
+
user: { _id: 1 },
|
|
43
|
+
}}
|
|
44
|
+
position='left'
|
|
45
|
+
showUserAvatar
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
53
48
|
|
|
54
|
-
expect(
|
|
49
|
+
expect(toJSON()).toMatchSnapshot()
|
|
55
50
|
})
|
|
56
51
|
|
|
57
52
|
it('should render null if user has no Avatar', () => {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
const { toJSON } = render(
|
|
54
|
+
<Message
|
|
55
|
+
key='123'
|
|
56
|
+
user={{ _id: 1 }}
|
|
57
|
+
currentMessage={{
|
|
58
|
+
_id: 1,
|
|
59
|
+
text: 'test',
|
|
60
|
+
createdAt: 1554744013721,
|
|
61
|
+
user: {
|
|
64
62
|
_id: 1,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
position='left'
|
|
73
|
-
showUserAvatar
|
|
74
|
-
/>
|
|
75
|
-
)
|
|
76
|
-
.toJSON()
|
|
63
|
+
avatar: null,
|
|
64
|
+
},
|
|
65
|
+
}}
|
|
66
|
+
position='left'
|
|
67
|
+
showUserAvatar
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
77
70
|
|
|
78
|
-
expect(
|
|
71
|
+
expect(toJSON()).toMatchSnapshot()
|
|
79
72
|
})
|
|
80
73
|
})
|
|
@@ -1,11 +1,45 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { MessageContainer } from '../GiftedChat'
|
|
5
|
+
import { DEFAULT_TEST_MESSAGE } from './data'
|
|
6
6
|
|
|
7
|
-
it('should render <MessageContainer />
|
|
8
|
-
|
|
7
|
+
it('should render <MessageContainer /> without crashing', () => {
|
|
8
|
+
render(
|
|
9
|
+
<MessageContainer
|
|
10
|
+
messages={[DEFAULT_TEST_MESSAGE]}
|
|
11
|
+
user={{ _id: 'test' }}
|
|
12
|
+
/>
|
|
13
|
+
)
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
// Just verify it renders without throwing
|
|
16
|
+
expect(() => render(
|
|
17
|
+
<MessageContainer
|
|
18
|
+
messages={[DEFAULT_TEST_MESSAGE]}
|
|
19
|
+
user={{ _id: 'test' }}
|
|
20
|
+
/>
|
|
21
|
+
)).not.toThrow()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should render <MessageContainer /> with multiple messages', () => {
|
|
25
|
+
const messages = [
|
|
26
|
+
{ ...DEFAULT_TEST_MESSAGE, _id: 'test1' },
|
|
27
|
+
{ ...DEFAULT_TEST_MESSAGE, _id: 'test2' },
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
expect(() => render(
|
|
31
|
+
<MessageContainer
|
|
32
|
+
messages={messages}
|
|
33
|
+
user={{ _id: 'test' }}
|
|
34
|
+
/>
|
|
35
|
+
)).not.toThrow()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('should render <MessageContainer /> with empty messages', () => {
|
|
39
|
+
expect(() => render(
|
|
40
|
+
<MessageContainer
|
|
41
|
+
messages={[]}
|
|
42
|
+
user={{ _id: 'test' }}
|
|
43
|
+
/>
|
|
44
|
+
)).not.toThrow()
|
|
11
45
|
})
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { MessageImage } from '../GiftedChat'
|
|
6
5
|
import { DEFAULT_TEST_MESSAGE } from './data'
|
|
7
6
|
|
|
8
7
|
describe('MessageImage', () => {
|
|
9
8
|
it('should not render <MessageImage /> and compare with snapshot', () => {
|
|
10
|
-
const
|
|
11
|
-
expect(
|
|
9
|
+
const { toJSON } = render(<MessageImage />)
|
|
10
|
+
expect(toJSON()).toMatchSnapshot()
|
|
12
11
|
})
|
|
13
12
|
|
|
14
13
|
it('should render <MessageImage /> and compare with snapshot', () => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.toJSON()
|
|
25
|
-
expect(tree).toMatchSnapshot()
|
|
14
|
+
const { toJSON } = render(
|
|
15
|
+
<MessageImage
|
|
16
|
+
currentMessage={{
|
|
17
|
+
...DEFAULT_TEST_MESSAGE,
|
|
18
|
+
image: 'url://to/image.png',
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
expect(toJSON()).toMatchSnapshot()
|
|
26
23
|
})
|
|
27
24
|
})
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { MessageText } from '../GiftedChat'
|
|
6
5
|
|
|
7
6
|
it('should render <MessageText /> and compare with snapshot', () => {
|
|
8
|
-
const
|
|
7
|
+
const { toJSON } = render(
|
|
8
|
+
<MessageText
|
|
9
|
+
currentMessage={{ _id: 1, createdAt: new Date(), text: 'test message' }}
|
|
10
|
+
/>
|
|
11
|
+
)
|
|
9
12
|
|
|
10
|
-
expect(
|
|
13
|
+
expect(toJSON()).toMatchSnapshot()
|
|
11
14
|
})
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { Send } from '../GiftedChat'
|
|
6
5
|
|
|
7
6
|
describe('Send', () => {
|
|
8
7
|
it('should not render <Send /> and compare with snapshot', () => {
|
|
9
|
-
const
|
|
10
|
-
expect(
|
|
8
|
+
const { toJSON } = render(<Send />)
|
|
9
|
+
expect(toJSON()).toMatchSnapshot()
|
|
11
10
|
})
|
|
12
11
|
|
|
13
12
|
it('should always render <Send /> and compare with snapshot', () => {
|
|
14
|
-
const
|
|
15
|
-
expect(
|
|
13
|
+
const { toJSON } = render(<Send alwaysShowSend />)
|
|
14
|
+
expect(toJSON()).toMatchSnapshot()
|
|
16
15
|
})
|
|
17
16
|
|
|
18
17
|
it('should render <Send /> where there is input and compare with snapshot', () => {
|
|
19
|
-
const
|
|
20
|
-
expect(
|
|
18
|
+
const { toJSON } = render(<Send text='test input' />)
|
|
19
|
+
expect(toJSON()).toMatchSnapshot()
|
|
21
20
|
})
|
|
22
21
|
})
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { SystemMessage } from '../GiftedChat'
|
|
6
5
|
import { DEFAULT_TEST_MESSAGE } from './data'
|
|
7
6
|
|
|
8
7
|
describe('SystemMessage', () => {
|
|
9
8
|
it('should not render <SystemMessage /> and compare with snapshot', () => {
|
|
10
|
-
const
|
|
11
|
-
expect(
|
|
9
|
+
const { toJSON } = render(<SystemMessage />)
|
|
10
|
+
expect(toJSON()).toMatchSnapshot()
|
|
12
11
|
})
|
|
13
12
|
|
|
14
13
|
it('should render <SystemMessage /> and compare with snapshot', () => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.toJSON()
|
|
25
|
-
expect(tree).toMatchSnapshot()
|
|
14
|
+
const { toJSON } = render(
|
|
15
|
+
<SystemMessage
|
|
16
|
+
currentMessage={{
|
|
17
|
+
...DEFAULT_TEST_MESSAGE,
|
|
18
|
+
system: true,
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
expect(toJSON()).toMatchSnapshot()
|
|
26
23
|
})
|
|
27
24
|
})
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import 'react-native'
|
|
2
1
|
import React from 'react'
|
|
3
|
-
import
|
|
2
|
+
import { render } from '@testing-library/react-native'
|
|
4
3
|
|
|
5
4
|
import { Time } from '../GiftedChat'
|
|
6
5
|
import { DEFAULT_TEST_MESSAGE } from './data'
|
|
7
6
|
|
|
8
7
|
describe('Time', () => {
|
|
9
8
|
it('should not render <Time /> and compare with snapshot', () => {
|
|
10
|
-
const
|
|
11
|
-
const tree = component.toJSON()
|
|
9
|
+
const { toJSON } = render(<Time />)
|
|
12
10
|
|
|
13
|
-
expect(
|
|
11
|
+
expect(toJSON()).toMatchSnapshot()
|
|
14
12
|
})
|
|
15
13
|
|
|
16
14
|
it('should render <Time /> and compare with snapshot', () => {
|
|
17
|
-
const
|
|
15
|
+
const { toJSON } = render(
|
|
18
16
|
<Time
|
|
19
17
|
currentMessage={{
|
|
20
18
|
...DEFAULT_TEST_MESSAGE,
|
|
@@ -22,8 +20,7 @@ describe('Time', () => {
|
|
|
22
20
|
}}
|
|
23
21
|
/>
|
|
24
22
|
)
|
|
25
|
-
const tree = component.toJSON()
|
|
26
23
|
|
|
27
|
-
expect(
|
|
24
|
+
expect(toJSON()).toMatchSnapshot()
|
|
28
25
|
})
|
|
29
26
|
})
|
|
@@ -22,7 +22,34 @@ exports[`should render <Actions /> and compare with snapshot 1`] = `
|
|
|
22
22
|
accessible={true}
|
|
23
23
|
collapsable={false}
|
|
24
24
|
focusable={true}
|
|
25
|
+
jestAnimatedProps={
|
|
26
|
+
{
|
|
27
|
+
"value": {},
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
jestAnimatedStyle={
|
|
31
|
+
{
|
|
32
|
+
"value": {
|
|
33
|
+
"opacity": 1,
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
jestInlineStyle={
|
|
38
|
+
[
|
|
39
|
+
[
|
|
40
|
+
{
|
|
41
|
+
"height": 26,
|
|
42
|
+
"marginBottom": 10,
|
|
43
|
+
"marginLeft": 10,
|
|
44
|
+
"width": 26,
|
|
45
|
+
},
|
|
46
|
+
undefined,
|
|
47
|
+
],
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
onBlur={[Function]}
|
|
25
51
|
onClick={[Function]}
|
|
52
|
+
onFocus={[Function]}
|
|
26
53
|
onResponderGrant={[Function]}
|
|
27
54
|
onResponderMove={[Function]}
|
|
28
55
|
onResponderRelease={[Function]}
|
|
@@ -30,13 +57,18 @@ exports[`should render <Actions /> and compare with snapshot 1`] = `
|
|
|
30
57
|
onResponderTerminationRequest={[Function]}
|
|
31
58
|
onStartShouldSetResponder={[Function]}
|
|
32
59
|
style={
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
[
|
|
61
|
+
{
|
|
62
|
+
"height": 26,
|
|
63
|
+
"marginBottom": 10,
|
|
64
|
+
"marginLeft": 10,
|
|
65
|
+
"width": 26,
|
|
66
|
+
},
|
|
67
|
+
undefined,
|
|
68
|
+
{
|
|
69
|
+
"opacity": 1,
|
|
70
|
+
},
|
|
71
|
+
]
|
|
40
72
|
}
|
|
41
73
|
>
|
|
42
74
|
<View
|