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