@@ -9,7 +9,6 @@ import { MessageSimple } from '../MessageSimple';
9
9
import { ACTIONS_NOT_WORKING_IN_THREAD , MESSAGE_ACTIONS } from '../utils' ;
10
10
11
11
import { Attachment } from '../../Attachment' ;
12
- import { MessageActions as MessageActionsMock } from '../../MessageActions' ;
13
12
14
13
import { ChannelActionProvider } from '../../../context/ChannelActionContext' ;
15
14
import { ChannelStateProvider } from '../../../context/ChannelStateContext' ;
@@ -23,9 +22,7 @@ import {
23
22
getTestClientWithUser ,
24
23
} from '../../../mock-builders' ;
25
24
26
- jest . mock ( '../../MessageActions' , ( ) => ( {
27
- MessageActions : jest . fn ( ( ) => < div /> ) ,
28
- } ) ) ;
25
+ const MESSAGE_ACTIONS_TEST_ID = 'message-actions' ;
29
26
30
27
const minimumCapabilitiesToRenderMessageActions = { 'delete-any-message' : true } ;
31
28
const alice = generateUser ( { name : 'alice' } ) ;
@@ -185,122 +182,122 @@ describe('<MessageOptions />', () => {
185
182
} ) ;
186
183
187
184
it ( 'should render message actions' , async ( ) => {
188
- await renderMessageOptions ( {
185
+ const { queryByTestId } = await renderMessageOptions ( {
189
186
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
190
187
} ) ;
191
- // eslint-disable-next-line jest/prefer-called-with
192
- expect ( MessageActionsMock ) . toHaveBeenCalled ( ) ;
188
+
189
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . toBeInTheDocument ( ) ;
193
190
} ) ;
194
191
195
192
it ( 'should not show message actions button if actions are disabled' , async ( ) => {
196
- await renderMessageOptions ( {
193
+ const { queryByTestId } = await renderMessageOptions ( {
197
194
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
198
195
customMessageProps : { messageActions : [ ] } ,
199
196
} ) ;
200
- expect ( MessageActionsMock ) . ;
197
+
198
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . not . toBeInTheDocument ( ) ;
201
199
} ) ;
202
200
203
201
it ( 'should not show actions box for message in thread if only non-thread actions are available' , async ( ) => {
204
- await renderMessageOptions ( {
202
+ const { queryByTestId } = await renderMessageOptions ( {
205
203
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
206
204
customMessageProps : { messageActions : ACTIONS_NOT_WORKING_IN_THREAD , threadList : true } ,
207
205
} ) ;
208
- expect ( MessageActionsMock ) . not . toHaveBeenCalled ( ) ;
206
+
207
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . not . toBeInTheDocument ( ) ;
209
208
} ) ;
210
209
211
210
it ( 'should show actions box for message in thread if not only non-thread actions are available' , async ( ) => {
212
- await renderMessageOptions ( {
211
+ const { queryByTestId } = await renderMessageOptions ( {
213
212
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
214
213
customMessageProps : {
215
214
messageActions : [ ...ACTIONS_NOT_WORKING_IN_THREAD , MESSAGE_ACTIONS . delete ] ,
216
215
threadList : true ,
217
216
} ,
218
217
} ) ;
219
- // eslint-disable-next-line jest/prefer-called-with
220
- expect ( MessageActionsMock ) . toHaveBeenCalled ( ) ;
218
+
219
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . toBeInTheDocument ( ) ;
221
220
} ) ;
222
221
223
222
it ( 'should show actions box for a message in thread if custom actions provided are non-thread' , async ( ) => {
224
- await renderMessageOptions ( {
223
+ const { queryByTestId } = await renderMessageOptions ( {
225
224
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
226
225
customMessageProps : {
227
226
customMessageActions : ACTIONS_NOT_WORKING_IN_THREAD ,
228
227
messageActions : ACTIONS_NOT_WORKING_IN_THREAD ,
229
228
threadList : true ,
230
229
} ,
231
230
} ) ;
232
- // eslint-disable-next-line jest/prefer-called-with
233
- expect ( MessageActionsMock ) . toHaveBeenCalled ( ) ;
231
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . toBeInTheDocument ( ) ;
234
232
} ) ;
235
233
236
234
it ( 'should not show actions box for message outside thread with single action "react"' , async ( ) => {
237
- await renderMessageOptions ( {
235
+ const { queryByTestId } = await renderMessageOptions ( {
238
236
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
239
237
customMessageProps : {
240
238
messageActions : [ MESSAGE_ACTIONS . react ] ,
241
239
} ,
242
240
} ) ;
243
- // eslint-disable-next-line jest/prefer-called-with
244
- expect ( MessageActionsMock ) . not . toHaveBeenCalled ( ) ;
241
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . not . toBeInTheDocument ( ) ;
245
242
} ) ;
246
243
247
244
it ( 'should show actions box for message outside thread with single action "react" if custom actions available' , async ( ) => {
248
- await renderMessageOptions ( {
245
+ const { queryByTestId } = await renderMessageOptions ( {
249
246
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
250
247
customMessageProps : {
251
248
customMessageActions : [ MESSAGE_ACTIONS . react ] ,
252
249
messageActions : [ MESSAGE_ACTIONS . react ] ,
253
250
} ,
254
251
} ) ;
255
- // eslint-disable-next-line jest/prefer-called-with
256
- expect ( MessageActionsMock ) . toHaveBeenCalled ( ) ;
252
+
253
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . toBeInTheDocument ( ) ;
257
254
} ) ;
258
255
259
256
it ( 'should not show actions box for message outside thread with single action "reply"' , async ( ) => {
260
- await renderMessageOptions ( {
257
+ const { queryByTestId } = await renderMessageOptions ( {
261
258
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
262
259
customMessageProps : {
263
260
messageActions : [ MESSAGE_ACTIONS . reply ] ,
264
261
} ,
265
262
} ) ;
266
- // eslint-disable-next-line jest/prefer-called-with
267
- expect ( MessageActionsMock ) . not . toHaveBeenCalled ( ) ;
263
+
264
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . not . toBeInTheDocument ( ) ;
268
265
} ) ;
269
266
270
267
it ( 'should show actions box for message outside thread with single action "reply" if custom actions available' , async ( ) => {
271
- await renderMessageOptions ( {
268
+ const { queryByTestId } = await renderMessageOptions ( {
272
269
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
273
270
customMessageProps : {
274
271
customMessageActions : [ MESSAGE_ACTIONS . reply ] ,
275
272
messageActions : [ MESSAGE_ACTIONS . reply ] ,
276
273
} ,
277
274
} ) ;
278
- // eslint-disable-next-line jest/prefer-called-with
279
- expect ( MessageActionsMock ) . toHaveBeenCalled ( ) ;
275
+
276
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . toBeInTheDocument ( ) ;
280
277
} ) ;
281
278
282
279
it ( 'should not show actions box for message outside thread with two actions "react" & "reply"' , async ( ) => {
283
280
const actions = [ MESSAGE_ACTIONS . react , MESSAGE_ACTIONS . reply ] ;
284
- await renderMessageOptions ( {
281
+ const { queryByTestId } = await renderMessageOptions ( {
285
282
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
286
283
customMessageProps : {
287
284
messageActions : actions ,
288
285
} ,
289
286
} ) ;
290
- // eslint-disable-next-line jest/prefer-called-with
291
- expect ( MessageActionsMock ) . not . toHaveBeenCalled ( ) ;
287
+
288
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . not . toBeInTheDocument ( ) ;
292
289
} ) ;
293
290
294
291
it ( 'should show actions box for message outside thread with single actions "react" & "reply" if custom actions available' , async ( ) => {
295
292
const actions = [ MESSAGE_ACTIONS . react , MESSAGE_ACTIONS . reply ] ;
296
- await renderMessageOptions ( {
293
+ const { queryByTestId } = await renderMessageOptions ( {
297
294
channelStateOpts : { channelCapabilities : minimumCapabilitiesToRenderMessageActions } ,
298
295
customMessageProps : {
299
296
customMessageActions : actions ,
300
297
messageActions : actions ,
301
298
} ,
302
299
} ) ;
303
- // eslint-disable-next-line jest/prefer-called-with
304
- expect ( MessageActionsMock ) . toHaveBeenCalled ( ) ;
300
+
301
+ expect ( queryByTestId ( MESSAGE_ACTIONS_TEST_ID ) ) . toBeInTheDocument ( ) ;
305
302
} ) ;
306
303
} ) ;
0 commit comments