Skip to content

Commit ac1f9a0

Browse files
committed
fix: issues resolved with tests for options bar
1 parent ce4e5b2 commit ac1f9a0

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

src/client/shared/services/core/http.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class HttpService {
101101
if (!lastAccessToken) {
102102
return 'Refresh API call failed';
103103
}
104-
const URL = returnValidURL('api', '/auth/refresh?lastToken=' + lastAccessToken + '&githubId=' + githubUserData.login);
104+
const URL = returnValidURL('api', '/auth/refresh?lastToken=' + lastAccessToken + '&githubId=' + githubUserData?.login);
105105
const options: any = {
106106
method: 'GET',
107107
};

src/client/web/app/common/components/chat-box/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class Chat extends Component<IChatProps, IChatState> {
207207
ownerId: githubUserData.id,
208208
memberId: contact.githubUid,
209209
groupName: `${githubUserData.name ||
210-
githubUserData.login} (${
210+
githubUserData?.login} (${
211211
githubUserData.realId
212212
}) - ${contact.name || contact.githubId} (${
213213
contact.id
@@ -294,7 +294,7 @@ class Chat extends Component<IChatProps, IChatState> {
294294
githubUserData.name && githubUserData.name.indexOf(' ') === -1
295295
? githubUserData.name
296296
: (githubUserData.name && githubUserData.name.split(' ')[0]) ||
297-
githubUserData.login;
297+
githubUserData?.login;
298298
const oppositeAvatarUrl = groupType === 'personal'
299299
? member.avatarUrl
300300
: groupImage;

src/client/web/app/common/components/options-bar/__tests__/options-bar-component.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import theme from '../../../styles';
88

99
// Web
1010
import OptionsBarComponent from '../index';
11+
import { act } from '@testing-library/react-hooks';
1112

1213
describe('OptionsBarComponent <OptionsBar />', () => {
1314
it('OptionsBar Component renders correctly', () => {
@@ -46,6 +47,11 @@ describe('OptionsBarComponent <OptionsBar />', () => {
4647
</ThemeProvider>
4748
);
4849

50+
act(() => {
51+
(optionsBarComponent.find('WithStyles(ForwardRef(Menu))').props() as any).onClose(() => {});
52+
(optionsBarComponent.find('WithStyles(ForwardRef(MenuItem))').first().props() as any).onClick(() => {});
53+
})
54+
4955
expect(optionsBarComponent.length).toBeTruthy();
5056
});
5157
});

src/client/web/app/containers/chat/__tests__/chat-container.spec.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Library
12
import React from 'react';
23
import { ApolloProvider } from 'react-apollo';
34
import { createMockClient } from 'mock-apollo-client';
@@ -14,6 +15,7 @@ import ChatContainer from '@omega-web-containers/chat';
1415
// Redux Model
1516
import { ChatReduxModel } from '@omega-state-machines/chat/chat.redux-model';
1617
import theme from '../../../common/styles';
18+
import { act } from '@testing-library/react-hooks';
1719

1820
interface IState {
1921
chats: {
@@ -98,6 +100,15 @@ describe('container <ChatContainer />', () => {
98100
'groupData'
99101
];
100102

103+
act(() => {
104+
component.props().onSelectGroup();
105+
component.props().onSelectContact();
106+
component.props().submitCreateGroup();
107+
component.props().readUsersAndChat();
108+
component.props().SharedComponent();
109+
component.props().submitChat();
110+
});
111+
101112
expect(Object.keys(component.props())).toEqual(
102113
expect.arrayContaining(expectedPropKeys)
103114
);

src/client/web/app/containers/chat/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class ChatContainer extends Component<any, any> {
4242
submitChat={(payload: ICreateChatPayload) =>
4343
dispatchCreateChat({
4444
apolloClient,
45-
data: payload.variables,
45+
data: payload?.variables,
4646
callBack: () => payload.callBack()
4747
})}
48-
onSelectContact={(groupId: Number) =>
48+
onSelectContact={(groupId: number) =>
4949
dispatchReadAllUsersAndChats({
5050
apolloClient,
5151
data: {
@@ -68,14 +68,14 @@ class ChatContainer extends Component<any, any> {
6868
profilePayload: {
6969
filters: {
7070
not: {
71-
githubId: githubUserData.login
71+
githubId: githubUserData?.login
7272
}
7373
}
7474
}
7575
},
7676
idToken
7777
})}
78-
onSelectGroup={(groupId: Number) =>
78+
onSelectGroup={(groupId: number) =>
7979
dispatchReadAllUsersAndChats({
8080
apolloClient,
8181
data: {
@@ -98,7 +98,7 @@ class ChatContainer extends Component<any, any> {
9898
profilePayload: {
9999
filters: {
100100
not: {
101-
githubId: githubUserData.login
101+
githubId: githubUserData?.login
102102
}
103103
}
104104
}
@@ -128,7 +128,7 @@ class ChatContainer extends Component<any, any> {
128128
profilePayload: {
129129
filters: {
130130
not: {
131-
githubId: githubUserData.login
131+
githubId: githubUserData?.login
132132
}
133133
}
134134
}
@@ -138,7 +138,7 @@ class ChatContainer extends Component<any, any> {
138138
submitCreateGroup={(payload: ICreateGroupPayload) =>
139139
dispatchCreateGroup({
140140
apolloClient,
141-
data: payload.variables,
141+
data: payload?.variables,
142142
callBack: id => payload.callBack(id)
143143
})}
144144
githubUserData={githubUserData}

0 commit comments

Comments
 (0)