Skip to content

Commit e82a443

Browse files
committed
fix: all tests
1 parent cdfff82 commit e82a443

File tree

9 files changed

+316
-300
lines changed

9 files changed

+316
-300
lines changed

src/client/shared/services/chat/__tests__/chat-service.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import { ChatServiceEngine } from '..';
77
const apolloClientMock = createMockClient();
88

99
describe('Chat Service', () => {
10+
it('can get chats', () => {
11+
const allChats = ChatServiceEngine.requestChats({
12+
apolloClientMock,
13+
data: {}
14+
});
15+
expect(allChats).toStrictEqual({});
16+
});
17+
1018
it('can get all chats', () => {
1119
const allChats = ChatServiceEngine.requestAllChats({
1220
apolloClientMock,

src/client/shared/services/chat/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class ChatService {
8080

8181
export const ChatServiceEngine = {
8282
requestAllChats: action => ChatService.getAllChats(action),
83+
requestChats: action => ChatService.getChats(action),
8384
requestAllChatsRest: action => ChatService.getChatsRest(action),
8485
requestCreateChat: (payload: any) => ChatService.createChat(payload),
8586
requestRemoveChat: (chatId: any) => ChatService.removeChat(chatId),

src/client/web/app/common/components/chat-box/__tests__/chat-box-component.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ describe('ChatBoxComponent <ChatBoxComponent />', () => {
2828
groupId={1}
2929
title={'title'}
3030
chatData={{}}
31-
userData={{}}
31+
userData={[]}
3232
groupData={{}}
3333
/>
3434
</ThemeProvider>
3535
);
3636

3737
// Interaction demo
3838
expect(chatBoxComponent.text()).toEqual(
39-
'<WithWidth(WithStyles(withI18nextTranslation(Chat))) />'
39+
'<Chat />'
4040
);
4141

4242
// Snapshot demo
@@ -57,7 +57,7 @@ describe('ChatBoxComponent <ChatBoxComponent />', () => {
5757
groupId={1}
5858
title={'title'}
5959
chatData={{}}
60-
userData={{}}
60+
userData={[]}
6161
groupData={{}}
6262
/>
6363
</ThemeProvider>

src/client/web/app/common/components/chat-box/chat-box.model.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import PropTypes from 'prop-types';
66
import classNames from 'classnames';
77
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
88
import JWTDecode from 'jwt-decode';
9-
import i18next from 'i18next';
10-
import { withTranslation } from 'react-i18next';
9+
import { useTranslation } from 'react-i18next';
1110

1211
// Material UI
1312
import withWidth, { isWidthUp } from '@material-ui/core/withWidth';
@@ -44,19 +43,18 @@ import ModalForm from '@omega-web-components/modal-form';
4443
import Tabs from '@omega-web-components/tabs';
4544
import SettingsForm from '@omega-web-components/settings';
4645
import CreateGroupForm from '@omega-web-components/create-group';
47-
import ChatStyles from './styles';
46+
import useChatStyles from './styles';
4847

49-
export const ChatBoxModel = {
48+
export const ChatBoxModel: any = {
5049
libraries: {
5150
React,
5251
Component,
5352
PropTypes,
5453
classNames,
5554
distanceInWordsToNow,
5655
JWTDecode,
57-
i18next,
5856
SplitPane,
59-
withTranslation,
57+
useTranslation,
6058
reject,
6159
find
6260
},
@@ -118,6 +116,6 @@ export const ChatBoxModel = {
118116
GroupWorkIcon,
119117
},
120118
styles: {
121-
ChatStyles,
119+
useChatStyles,
122120
},
123121
};

src/client/web/app/common/components/chat-box/functional-components/chat-header.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const ChatHeaderComponent: React.FunctionComponent<ChatHeaderProps> = ({
9595
<ListItem>
9696
<Avatar
9797
alt=''
98-
src={githubUserData.avatar_url}
98+
src={githubUserData?.avatar_url}
9999
className={classes.avatar}
100100
/>
101101
<ListItemText primary={currentUsername} secondary='Online' />
@@ -125,7 +125,7 @@ export const ChatHeaderComponent: React.FunctionComponent<ChatHeaderProps> = ({
125125
modalContent={() => (
126126
<CreateGroupForm
127127
groupMembers={groupMembers}
128-
ownerId={githubUserData.id}
128+
ownerId={githubUserData?.id}
129129
ownerRealId={ownerRealId}
130130
onSubmit={handleCreateGroup}
131131
closeForm={() => modalHandleClose('createGroupForm')}

src/client/web/app/common/components/chat-box/functional-components/chat-main.component.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const ChatMainComponent: React.FunctionComponent<
3636
key={`ChatItem-${chat.id}`}
3737
className={classNames(
3838
classes.conversation,
39-
chat.ownerId === githubUserData.id
39+
chat.ownerId === githubUserData?.id
4040
? classes.conversationSent
4141
: classes.conversationReceived
4242
)}
@@ -47,15 +47,15 @@ export const ChatMainComponent: React.FunctionComponent<
4747
style={{
4848
marginRight: 10,
4949
display:
50-
chat.ownerId === githubUserData.id
50+
chat.ownerId === githubUserData?.id
5151
? 'none'
5252
: 'block'
5353
}}
5454
/>
5555
<div
5656
className={classNames(
5757
classes.body,
58-
chat.ownerId === githubUserData.id
58+
chat.ownerId === githubUserData?.id
5959
? classes.bodySent
6060
: classes.bodyReceived
6161
)}
@@ -65,7 +65,7 @@ export const ChatMainComponent: React.FunctionComponent<
6565
variant='caption'
6666
className={classNames(
6767
classes.date,
68-
chat.ownerId === githubUserData.id
68+
chat.ownerId === githubUserData?.id
6969
? classes.dateSent
7070
: classes.dateReceived
7171
)}
@@ -76,14 +76,14 @@ export const ChatMainComponent: React.FunctionComponent<
7676
</div>
7777
<Avatar
7878
alt=''
79-
src={githubUserData.avatar_url}
79+
src={githubUserData?.avatar_url}
8080
style={{
8181
float: 'right',
8282
order: 2,
8383
marginLeft: 10,
8484
top: 25,
8585
display:
86-
chat.ownerId === githubUserData.id
86+
chat.ownerId === githubUserData?.id
8787
? 'block'
8888
: 'none'
8989
}}

0 commit comments

Comments
 (0)