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',
type: 'warning',
},
}, {
type: constants.INIT,
}, {
type: constants.NOTIFY,
payload: {

View File

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