Skip to content

Commit 2d9e5a9

Browse files
committed
fixed errors in test
1 parent 44fc7d5 commit 2d9e5a9

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

src/screens/UserPortal/Chat/Chat.spec.tsx

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
UNREAD_CHAT_LIST,
3030
} from 'GraphQl/Queries/PlugInQueries';
3131
import useLocalStorage from 'utils/useLocalstorage';
32+
import { StaticMockLink } from 'utils/StaticMockLink';
3233
// import userEvent from '@testing-library/user-event';
3334

3435
/**
@@ -4289,9 +4290,27 @@ describe('Testing Chat Screen [User Portal]', () => {
42894290
{
42904291
_id: '1',
42914292
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+
],
42934302
messages: [],
4303+
name: null,
4304+
image: null,
42944305
unseenMessagesByUsers: '{}',
4306+
creator: {
4307+
_id: '1',
4308+
firstName: 'John',
4309+
lastName: 'Doe',
4310+
4311+
},
4312+
organization: null,
4313+
admins: [],
42954314
},
42964315
],
42974316
};
@@ -4319,13 +4338,44 @@ describe('Testing Chat Screen [User Portal]', () => {
43194338
},
43204339
},
43214340
},
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+
},
43224370
];
4323-
4371+
const link = new StaticMockLink(mocks, true);
43244372
render(
4325-
<MockedProvider mocks={mocks} addTypename={false}>
4373+
<MockedProvider link={link} addTypename={false}>
43264374
<BrowserRouter>
43274375
<Provider store={store}>
4328-
<Chat />
4376+
<I18nextProvider i18n={i18nForTest}>
4377+
<Chat />
4378+
</I18nextProvider>
43294379
</Provider>
43304380
</BrowserRouter>
43314381
</MockedProvider>,
@@ -4387,6 +4437,7 @@ describe('Testing Chat Screen [User Portal]', () => {
43874437
const contactCards = await screen.findAllByTestId('contactCardContainer');
43884438
expect(contactCards).toHaveLength(1);
43894439
});
4440+
43904441
test('Screen should be rendered properly', async () => {
43914442
render(
43924443
<MockedProvider addTypename={false} mocks={mock}>
@@ -4514,6 +4565,7 @@ describe('Testing Chat Screen [User Portal]', () => {
45144565
fireEvent.click(await screen.findByTestId('allChat'));
45154566
});
45164567
});
4568+
45174569
it('should fetch and set group chats when filterType is "group"', async () => {
45184570
setItem('userId', '1');
45194571

0 commit comments

Comments
 (0)