Fix CallActions.test.ts

This commit is contained in:
Jerko Steiner 2020-03-10 13:14:31 +01:00
parent 9db349d4a5
commit 720e26a5dd
2 changed files with 15 additions and 10 deletions

View File

@ -74,6 +74,8 @@ describe('CallActions', () => {
message: 'Connected to server socket', message: 'Connected to server socket',
type: 'warning', type: 'warning',
}, },
}, {
type: constants.INIT,
}, { }, {
type: constants.NOTIFY, type: constants.NOTIFY,
payload: { payload: {

View File

@ -19,6 +19,7 @@ const initialize = (): InitializeAction => ({
export const init = (): ThunkResult<Promise<void>> => export const init = (): ThunkResult<Promise<void>> =>
async (dispatch, getState) => { async (dispatch, getState) => {
return new Promise(resolve => {
socket.on('connect', () => { socket.on('connect', () => {
dispatch(NotifyActions.warning('Connected to server socket')) dispatch(NotifyActions.warning('Connected to server socket'))
dispatch(SocketActions.handshake({ dispatch(SocketActions.handshake({
@ -26,8 +27,10 @@ async (dispatch, getState) => {
roomName: callId, roomName: callId,
})) }))
dispatch(initialize()) dispatch(initialize())
resolve()
}) })
socket.on('disconnect', () => { socket.on('disconnect', () => {
dispatch(NotifyActions.error('Server socket disconnected')) dispatch(NotifyActions.error('Server socket disconnected'))
}) })
})
} }