@@ -29,6 +29,7 @@ import {
29
29
UNREAD_CHAT_LIST ,
30
30
} from 'GraphQl/Queries/PlugInQueries' ;
31
31
import useLocalStorage from 'utils/useLocalstorage' ;
32
+ import { StaticMockLink } from 'utils/StaticMockLink' ;
32
33
// import userEvent from '@testing-library/user-event';
33
34
34
35
/**
@@ -4289,9 +4290,27 @@ describe('Testing Chat Screen [User Portal]', () => {
4289
4290
{
4290
4291
_id : '1' ,
4291
4292
isGroup : false ,
4292
- users : [ { _id : '1' , firstName : 'John' , lastName : 'Doe' } ] ,
4293
+ users : [
4294
+ {
4295
+ _id : '1' ,
4296
+ firstName : 'John' ,
4297
+ lastName : 'Doe' ,
4298
+
4299
+ image : null ,
4300
+ } ,
4301
+ ] ,
4293
4302
messages : [ ] ,
4303
+ name : null ,
4304
+ image : null ,
4294
4305
unseenMessagesByUsers : '{}' ,
4306
+ creator : {
4307
+ _id : '1' ,
4308
+ firstName : 'John' ,
4309
+ lastName : 'Doe' ,
4310
+
4311
+ } ,
4312
+ organization : null ,
4313
+ admins : [ ] ,
4295
4314
} ,
4296
4315
] ,
4297
4316
} ;
@@ -4319,13 +4338,44 @@ describe('Testing Chat Screen [User Portal]', () => {
4319
4338
} ,
4320
4339
} ,
4321
4340
} ,
4341
+ {
4342
+ request : {
4343
+ query : UNREAD_CHAT_LIST ,
4344
+ } ,
4345
+ result : {
4346
+ data : {
4347
+ getUnreadChatsByUserId : [ ] ,
4348
+ } ,
4349
+ } ,
4350
+ } ,
4351
+ {
4352
+ request : {
4353
+ query : GROUP_CHAT_LIST ,
4354
+ } ,
4355
+ result : {
4356
+ data : {
4357
+ getGroupChatsByUserId : [ ] ,
4358
+ } ,
4359
+ } ,
4360
+ } ,
4361
+ {
4362
+ request : {
4363
+ query : CHATS_LIST ,
4364
+ variables : { id : '1' } ,
4365
+ } ,
4366
+ result : {
4367
+ data : mockChatsData ,
4368
+ } ,
4369
+ } ,
4322
4370
] ;
4323
-
4371
+ const link = new StaticMockLink ( mocks , true ) ;
4324
4372
render (
4325
- < MockedProvider mocks = { mocks } addTypename = { false } >
4373
+ < MockedProvider link = { link } addTypename = { false } >
4326
4374
< BrowserRouter >
4327
4375
< Provider store = { store } >
4328
- < Chat />
4376
+ < I18nextProvider i18n = { i18nForTest } >
4377
+ < Chat />
4378
+ </ I18nextProvider >
4329
4379
</ Provider >
4330
4380
</ BrowserRouter >
4331
4381
</ MockedProvider > ,
@@ -4387,6 +4437,7 @@ describe('Testing Chat Screen [User Portal]', () => {
4387
4437
const contactCards = await screen . findAllByTestId ( 'contactCardContainer' ) ;
4388
4438
expect ( contactCards ) . toHaveLength ( 1 ) ;
4389
4439
} ) ;
4440
+
4390
4441
test ( 'Screen should be rendered properly' , async ( ) => {
4391
4442
render (
4392
4443
< MockedProvider addTypename = { false } mocks = { mock } >
@@ -4514,6 +4565,7 @@ describe('Testing Chat Screen [User Portal]', () => {
4514
4565
fireEvent . click ( await screen . findByTestId ( 'allChat' ) ) ;
4515
4566
} ) ;
4516
4567
} ) ;
4568
+
4517
4569
it ( 'should fetch and set group chats when filterType is "group"' , async ( ) => {
4518
4570
setItem ( 'userId' , '1' ) ;
4519
4571
0 commit comments