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.
Files changed (203) hide show
  1. package/README.md +51 -31
  2. package/package.json +28 -30
  3. package/src/Actions.tsx +1 -1
  4. package/src/Avatar.tsx +1 -1
  5. package/src/Bubble/index.tsx +24 -20
  6. package/src/Bubble/types.ts +7 -6
  7. package/src/Composer.tsx +19 -26
  8. package/src/Constant.ts +0 -1
  9. package/src/Day/index.tsx +3 -3
  10. package/src/GiftedAvatar.tsx +31 -38
  11. package/src/GiftedChat/index.tsx +59 -106
  12. package/src/GiftedChat/styles.ts +3 -0
  13. package/src/GiftedChat/types.ts +17 -67
  14. package/src/InputToolbar.tsx +27 -10
  15. package/src/LoadEarlier.tsx +22 -20
  16. package/src/Message/index.tsx +4 -18
  17. package/src/Message/types.ts +2 -2
  18. package/src/MessageAudio.tsx +19 -7
  19. package/src/MessageContainer/components/DayAnimated/index.tsx +16 -11
  20. package/src/MessageContainer/components/Item/index.tsx +10 -4
  21. package/src/MessageContainer/components/Item/types.ts +1 -1
  22. package/src/MessageContainer/index.tsx +57 -38
  23. package/src/MessageContainer/types.ts +32 -7
  24. package/src/MessageImage.tsx +132 -18
  25. package/src/MessageText.tsx +24 -64
  26. package/src/MessageVideo.tsx +19 -7
  27. package/src/QuickReplies.tsx +19 -12
  28. package/src/Send.tsx +10 -5
  29. package/src/SystemMessage.tsx +10 -3
  30. package/src/Time.tsx +10 -3
  31. package/src/TypingIndicator/index.tsx +4 -3
  32. package/src/TypingIndicator/types.ts +3 -0
  33. package/src/__tests__/Actions.test.tsx +3 -4
  34. package/src/__tests__/Avatar.test.tsx +5 -6
  35. package/src/__tests__/Bubble.test.tsx +14 -19
  36. package/src/__tests__/Composer.test.tsx +3 -4
  37. package/src/__tests__/Day.test.tsx +5 -8
  38. package/src/__tests__/DayAnimated.test.tsx +12 -14
  39. package/src/__tests__/GiftedAvatar.test.tsx +3 -8
  40. package/src/__tests__/GiftedChat.test.tsx +34 -43
  41. package/src/__tests__/InputToolbar.test.tsx +3 -4
  42. package/src/__tests__/LoadEarlier.test.tsx +3 -4
  43. package/src/__tests__/Message.test.tsx +51 -58
  44. package/src/__tests__/MessageContainer.test.tsx +39 -5
  45. package/src/__tests__/MessageImage.test.tsx +12 -15
  46. package/src/__tests__/MessageText.test.tsx +7 -4
  47. package/src/__tests__/Send.test.tsx +7 -8
  48. package/src/__tests__/SystemMessage.test.tsx +12 -15
  49. package/src/__tests__/Time.test.tsx +5 -8
  50. package/src/__tests__/__snapshots__/Actions.test.tsx.snap +39 -7
  51. package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +48 -50
  52. package/src/__tests__/__snapshots__/Composer.test.tsx.snap +1 -2
  53. package/src/__tests__/__snapshots__/Constant.test.tsx.snap +0 -1
  54. package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +20 -22
  55. package/src/__tests__/__snapshots__/InputToolbar.test.tsx.snap +2 -2
  56. package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +37 -6
  57. package/src/__tests__/__snapshots__/Message.test.tsx.snap +146 -150
  58. package/src/__tests__/__snapshots__/MessageImage.test.tsx.snap +32 -11
  59. package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +12 -8
  60. package/src/__tests__/__snapshots__/Send.test.tsx.snap +72 -10
  61. package/src/components/TouchableOpacity.tsx +45 -0
  62. package/src/reanimatedCompat.ts +27 -0
  63. package/src/types.ts +4 -2
  64. package/src/utils.ts +2 -2
  65. package/lib/Actions.d.ts +0 -14
  66. package/lib/Actions.js +0 -57
  67. package/lib/Actions.js.map +0 -1
  68. package/lib/Avatar.d.ts +0 -18
  69. package/lib/Avatar.js +0 -93
  70. package/lib/Avatar.js.map +0 -1
  71. package/lib/Bubble/index.d.ts +0 -6
  72. package/lib/Bubble/index.js +0 -242
  73. package/lib/Bubble/index.js.map +0 -1
  74. package/lib/Bubble/styles.d.ts +0 -69
  75. package/lib/Bubble/styles.js +0 -72
  76. package/lib/Bubble/styles.js.map +0 -1
  77. package/lib/Bubble/types.d.ts +0 -47
  78. package/lib/Bubble/types.js +0 -2
  79. package/lib/Bubble/types.js.map +0 -1
  80. package/lib/Color.d.ts +0 -18
  81. package/lib/Color.js +0 -18
  82. package/lib/Color.js.map +0 -1
  83. package/lib/Composer.d.ts +0 -20
  84. package/lib/Composer.js +0 -60
  85. package/lib/Composer.js.map +0 -1
  86. package/lib/Constant.d.ts +0 -10
  87. package/lib/Constant.js +0 -17
  88. package/lib/Constant.js.map +0 -1
  89. package/lib/Day/index.d.ts +0 -4
  90. package/lib/Day/index.js +0 -39
  91. package/lib/Day/index.js.map +0 -1
  92. package/lib/Day/styles.d.ts +0 -20
  93. package/lib/Day/styles.js +0 -22
  94. package/lib/Day/styles.js.map +0 -1
  95. package/lib/Day/types.d.ts +0 -9
  96. package/lib/Day/types.js +0 -2
  97. package/lib/Day/types.js.map +0 -1
  98. package/lib/GiftedAvatar.d.ts +0 -11
  99. package/lib/GiftedAvatar.js +0 -104
  100. package/lib/GiftedAvatar.js.map +0 -1
  101. package/lib/GiftedChat/index.d.ts +0 -26
  102. package/lib/GiftedChat/index.js +0 -317
  103. package/lib/GiftedChat/index.js.map +0 -1
  104. package/lib/GiftedChat/styles.d.ts +0 -6
  105. package/lib/GiftedChat/styles.js +0 -7
  106. package/lib/GiftedChat/styles.js.map +0 -1
  107. package/lib/GiftedChat/types.d.ts +0 -112
  108. package/lib/GiftedChat/types.js +0 -2
  109. package/lib/GiftedChat/types.js.map +0 -1
  110. package/lib/GiftedChatContext.d.ts +0 -9
  111. package/lib/GiftedChatContext.js +0 -9
  112. package/lib/GiftedChatContext.js.map +0 -1
  113. package/lib/InputToolbar.d.ts +0 -23
  114. package/lib/InputToolbar.js +0 -56
  115. package/lib/InputToolbar.js.map +0 -1
  116. package/lib/LoadEarlier.d.ts +0 -14
  117. package/lib/LoadEarlier.js +0 -45
  118. package/lib/LoadEarlier.js.map +0 -1
  119. package/lib/Message/index.d.ts +0 -6
  120. package/lib/Message/index.js +0 -80
  121. package/lib/Message/index.js.map +0 -1
  122. package/lib/Message/styles.d.ts +0 -21
  123. package/lib/Message/styles.js +0 -22
  124. package/lib/Message/styles.js.map +0 -1
  125. package/lib/Message/types.d.ts +0 -22
  126. package/lib/Message/types.js +0 -2
  127. package/lib/Message/types.js.map +0 -1
  128. package/lib/MessageAudio.d.ts +0 -2
  129. package/lib/MessageAudio.js +0 -14
  130. package/lib/MessageAudio.js.map +0 -1
  131. package/lib/MessageContainer/components/DayAnimated/index.d.ts +0 -5
  132. package/lib/MessageContainer/components/DayAnimated/index.js +0 -85
  133. package/lib/MessageContainer/components/DayAnimated/index.js.map +0 -1
  134. package/lib/MessageContainer/components/DayAnimated/styles.d.ts +0 -11
  135. package/lib/MessageContainer/components/DayAnimated/styles.js +0 -12
  136. package/lib/MessageContainer/components/DayAnimated/styles.js.map +0 -1
  137. package/lib/MessageContainer/components/DayAnimated/types.d.ts +0 -17
  138. package/lib/MessageContainer/components/DayAnimated/types.js +0 -2
  139. package/lib/MessageContainer/components/DayAnimated/types.js.map +0 -1
  140. package/lib/MessageContainer/components/Item/index.d.ts +0 -23
  141. package/lib/MessageContainer/components/Item/index.js +0 -88
  142. package/lib/MessageContainer/components/Item/index.js.map +0 -1
  143. package/lib/MessageContainer/components/Item/types.d.ts +0 -17
  144. package/lib/MessageContainer/components/Item/types.js +0 -2
  145. package/lib/MessageContainer/components/Item/types.js.map +0 -1
  146. package/lib/MessageContainer/index.d.ts +0 -6
  147. package/lib/MessageContainer/index.js +0 -235
  148. package/lib/MessageContainer/index.js.map +0 -1
  149. package/lib/MessageContainer/styles.d.ts +0 -35
  150. package/lib/MessageContainer/styles.js +0 -32
  151. package/lib/MessageContainer/styles.js.map +0 -1
  152. package/lib/MessageContainer/types.d.ts +0 -51
  153. package/lib/MessageContainer/types.js +0 -2
  154. package/lib/MessageContainer/types.js.map +0 -1
  155. package/lib/MessageImage.d.ts +0 -13
  156. package/lib/MessageImage.js +0 -30
  157. package/lib/MessageImage.js.map +0 -1
  158. package/lib/MessageText.d.ts +0 -19
  159. package/lib/MessageText.js +0 -69
  160. package/lib/MessageText.js.map +0 -1
  161. package/lib/MessageVideo.d.ts +0 -2
  162. package/lib/MessageVideo.js +0 -14
  163. package/lib/MessageVideo.js.map +0 -1
  164. package/lib/QuickReplies.d.ts +0 -15
  165. package/lib/QuickReplies.js +0 -101
  166. package/lib/QuickReplies.js.map +0 -1
  167. package/lib/Send.d.ts +0 -15
  168. package/lib/Send.js +0 -34
  169. package/lib/Send.js.map +0 -1
  170. package/lib/SystemMessage.d.ts +0 -11
  171. package/lib/SystemMessage.js +0 -27
  172. package/lib/SystemMessage.js.map +0 -1
  173. package/lib/Time.d.ts +0 -11
  174. package/lib/Time.js +0 -56
  175. package/lib/Time.js.map +0 -1
  176. package/lib/TypingIndicator/index.d.ts +0 -5
  177. package/lib/TypingIndicator/index.js +0 -94
  178. package/lib/TypingIndicator/index.js.map +0 -1
  179. package/lib/TypingIndicator/styles.d.ts +0 -20
  180. package/lib/TypingIndicator/styles.js +0 -22
  181. package/lib/TypingIndicator/styles.js.map +0 -1
  182. package/lib/TypingIndicator/types.d.ts +0 -3
  183. package/lib/TypingIndicator/types.js +0 -2
  184. package/lib/TypingIndicator/types.js.map +0 -1
  185. package/lib/hooks/useUpdateLayoutEffect.d.ts +0 -8
  186. package/lib/hooks/useUpdateLayoutEffect.js +0 -17
  187. package/lib/hooks/useUpdateLayoutEffect.js.map +0 -1
  188. package/lib/index.d.ts +0 -4
  189. package/lib/index.js +0 -5
  190. package/lib/index.js.map +0 -1
  191. package/lib/logging.d.ts +0 -2
  192. package/lib/logging.js +0 -5
  193. package/lib/logging.js.map +0 -1
  194. package/lib/styles.d.ts +0 -10
  195. package/lib/styles.js +0 -11
  196. package/lib/styles.js.map +0 -1
  197. package/lib/types.d.ts +0 -67
  198. package/lib/types.js +0 -2
  199. package/lib/types.js.map +0 -1
  200. package/lib/utils.d.ts +0 -5
  201. package/lib/utils.js +0 -83
  202. package/lib/utils.js.map +0 -1
  203. 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 renderer from 'react-test-renderer'
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 component = renderer.create(<Day />)
11
- const tree = component.toJSON()
9
+ const { toJSON } = render(<Day />)
12
10
 
13
- expect(tree).toMatchSnapshot()
11
+ expect(toJSON()).toMatchSnapshot()
14
12
  })
15
13
 
16
14
  it('should render <Day /> and compare with snapshot', () => {
17
- const component = renderer.create(
15
+ const { toJSON } = render(
18
16
  <Day currentMessage={DEFAULT_TEST_MESSAGE} />
19
17
  )
20
- const tree = component.toJSON()
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 renderer from 'react-test-renderer'
4
- import DayAnimated from '../MessageContainer/components/DayAnimated'
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 component = renderer.create(
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
- const tree = component.toJSON()
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) => <div data-testid='custom-day'>Custom Day: {props.createdAt}</div>)
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 component = renderer.create(
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
- // Force render to trigger the renderDay call if there's a createdAt
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 renderer from 'react-test-renderer'
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
- let tree
7
+ const { toJSON } = render(<GiftedAvatar />)
9
8
 
10
- renderer.act(() => {
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 renderer from 'react-test-renderer'
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
- let tree
22
-
23
- renderer.act(() => {
24
- (useReanimatedKeyboardAnimation as jest.Mock).mockReturnValue({
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
- expect(tree.toJSON()).toMatchSnapshot()
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 disableKeyboardController=true', () => {
45
- let tree
46
-
47
- renderer.act(() => {
48
- (useReanimatedKeyboardAnimation as jest.Mock).mockReturnValue({
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
- expect(tree.toJSON()).toMatchSnapshot()
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 renderer from 'react-test-renderer'
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 tree = renderer.create(<InputToolbar />).toJSON()
7
+ const { toJSON } = render(<InputToolbar />)
9
8
 
10
- expect(tree).toMatchSnapshot()
9
+ expect(toJSON()).toMatchSnapshot()
11
10
  })
@@ -1,11 +1,10 @@
1
- import 'react-native'
2
1
  import React from 'react'
3
- import renderer from 'react-test-renderer'
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 tree = renderer.create(<LoadEarlier />).toJSON()
7
+ const { toJSON } = render(<LoadEarlier />)
9
8
 
10
- expect(tree).toMatchSnapshot()
9
+ expect(toJSON()).toMatchSnapshot()
11
10
  })
@@ -1,80 +1,73 @@
1
- import 'react-native'
2
1
  import React from 'react'
3
- import renderer from 'react-test-renderer'
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 tree = renderer
10
- .create(
11
- <Message
12
- key='123'
13
- user={{ _id: 1 }}
14
- currentMessage={{
15
- _id: 1,
16
- text: 'test',
17
- createdAt: 1554744013721,
18
- user: { _id: 1 },
19
- }}
20
- position='left'
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(tree).toMatchSnapshot()
22
+ expect(toJSON()).toMatchSnapshot()
26
23
  })
27
24
 
28
25
  it('should NOT render <Message />', () => {
29
- const tree = renderer
30
- .create(<Message key='123' user={{ _id: 1 }} currentMessage={null} position='left' />)
31
- .toJSON()
26
+ const { toJSON } = render(
27
+ <Message key='123' user={{ _id: 1 }} currentMessage={null} position='left' />
28
+ )
32
29
 
33
- expect(tree).toMatchSnapshot()
30
+ expect(toJSON()).toMatchSnapshot()
34
31
  })
35
32
 
36
33
  it('should render <Message /> with Avatar', () => {
37
- const tree = renderer
38
- .create(
39
- <Message
40
- key='123'
41
- user={{ _id: 1 }}
42
- currentMessage={{
43
- _id: 1,
44
- text: 'test',
45
- createdAt: 1554744013721,
46
- user: { _id: 1 },
47
- }}
48
- position='left'
49
- showUserAvatar
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(tree).toMatchSnapshot()
49
+ expect(toJSON()).toMatchSnapshot()
55
50
  })
56
51
 
57
52
  it('should render null if user has no Avatar', () => {
58
- const tree = renderer
59
- .create(
60
- <Message
61
- key='123'
62
- user={{ _id: 1 }}
63
- currentMessage={{
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
- text: 'test',
66
- createdAt: 1554744013721,
67
- user: {
68
- _id: 1,
69
- avatar: null,
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(tree).toMatchSnapshot()
71
+ expect(toJSON()).toMatchSnapshot()
79
72
  })
80
73
  })
@@ -1,11 +1,45 @@
1
- import 'react-native'
2
1
  import React from 'react'
3
- import renderer from 'react-test-renderer'
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 /> and compare with snapshot', () => {
8
- const tree = renderer.create(<MessageContainer />).toJSON()
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
- expect(tree).toMatchSnapshot()
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 renderer from 'react-test-renderer'
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 tree = renderer.create(<MessageImage />).toJSON()
11
- expect(tree).toMatchSnapshot()
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 tree = renderer
16
- .create(
17
- <MessageImage
18
- currentMessage={{
19
- ...DEFAULT_TEST_MESSAGE,
20
- image: 'url://to/image.png',
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 renderer from 'react-test-renderer'
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 tree = renderer.create(<MessageText />).toJSON()
7
+ const { toJSON } = render(
8
+ <MessageText
9
+ currentMessage={{ _id: 1, createdAt: new Date(), text: 'test message' }}
10
+ />
11
+ )
9
12
 
10
- expect(tree).toMatchSnapshot()
13
+ expect(toJSON()).toMatchSnapshot()
11
14
  })
@@ -1,22 +1,21 @@
1
- import 'react-native'
2
1
  import React from 'react'
3
- import renderer from 'react-test-renderer'
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 tree = renderer.create(<Send />).toJSON()
10
- expect(tree).toMatchSnapshot()
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 tree = renderer.create(<Send alwaysShowSend />).toJSON()
15
- expect(tree).toMatchSnapshot()
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 tree = renderer.create(<Send text='test input' />).toJSON()
20
- expect(tree).toMatchSnapshot()
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 renderer from 'react-test-renderer'
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 tree = renderer.create(<SystemMessage />).toJSON()
11
- expect(tree).toMatchSnapshot()
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 tree = renderer
16
- .create(
17
- <SystemMessage
18
- currentMessage={{
19
- ...DEFAULT_TEST_MESSAGE,
20
- system: true,
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 renderer from 'react-test-renderer'
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 component = renderer.create(<Time />)
11
- const tree = component.toJSON()
9
+ const { toJSON } = render(<Time />)
12
10
 
13
- expect(tree).toMatchSnapshot()
11
+ expect(toJSON()).toMatchSnapshot()
14
12
  })
15
13
 
16
14
  it('should render <Time /> and compare with snapshot', () => {
17
- const component = renderer.create(
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(tree).toMatchSnapshot()
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
- "height": 26,
35
- "marginBottom": 10,
36
- "marginLeft": 10,
37
- "opacity": 1,
38
- "width": 26,
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