2020-11-06 17:36:37 +00:00
|
|
|
// Copyright 2019-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { assert } from 'chai';
|
2020-11-13 19:57:55 +00:00
|
|
|
import { CallMode, CallState } from '../../../types/Calling';
|
|
|
|
import { getIncomingCall } from '../../../state/selectors/calling';
|
|
|
|
import { getEmptyState, CallingStateType } from '../../../state/ducks/calling';
|
2020-11-06 17:36:37 +00:00
|
|
|
|
|
|
|
describe('state/selectors/calling', () => {
|
2020-11-13 19:57:55 +00:00
|
|
|
const stateWithDirectCall: CallingStateType = {
|
2020-11-06 17:36:37 +00:00
|
|
|
...getEmptyState(),
|
|
|
|
callsByConversation: {
|
|
|
|
'fake-direct-call-conversation-id': {
|
2020-11-13 19:57:55 +00:00
|
|
|
callMode: CallMode.Direct,
|
2020-11-06 17:36:37 +00:00
|
|
|
conversationId: 'fake-direct-call-conversation-id',
|
|
|
|
callState: CallState.Accepted,
|
|
|
|
isIncoming: false,
|
|
|
|
isVideoCall: false,
|
|
|
|
hasRemoteVideo: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-13 19:57:55 +00:00
|
|
|
const stateWithActiveDirectCall: CallingStateType = {
|
2020-11-06 17:36:37 +00:00
|
|
|
...stateWithDirectCall,
|
|
|
|
activeCallState: {
|
|
|
|
conversationId: 'fake-direct-call-conversation-id',
|
|
|
|
hasLocalAudio: true,
|
|
|
|
hasLocalVideo: false,
|
|
|
|
participantsList: false,
|
|
|
|
pip: false,
|
|
|
|
settingsDialogOpen: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-13 19:57:55 +00:00
|
|
|
const stateWithIncomingDirectCall: CallingStateType = {
|
2020-11-06 17:36:37 +00:00
|
|
|
...getEmptyState(),
|
|
|
|
callsByConversation: {
|
|
|
|
'fake-direct-call-conversation-id': {
|
2020-11-13 19:57:55 +00:00
|
|
|
callMode: CallMode.Direct,
|
2020-11-06 17:36:37 +00:00
|
|
|
conversationId: 'fake-direct-call-conversation-id',
|
|
|
|
callState: CallState.Ringing,
|
|
|
|
isIncoming: true,
|
|
|
|
isVideoCall: false,
|
|
|
|
hasRemoteVideo: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('getIncomingCall', () => {
|
|
|
|
it('returns undefined if there are no calls', () => {
|
|
|
|
assert.isUndefined(getIncomingCall(getEmptyState()));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns undefined if there is no incoming call', () => {
|
|
|
|
assert.isUndefined(getIncomingCall(stateWithDirectCall));
|
|
|
|
assert.isUndefined(getIncomingCall(stateWithActiveDirectCall));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns the incoming call', () => {
|
|
|
|
assert.deepEqual(getIncomingCall(stateWithIncomingDirectCall), {
|
2020-11-13 19:57:55 +00:00
|
|
|
callMode: CallMode.Direct,
|
2020-11-06 17:36:37 +00:00
|
|
|
conversationId: 'fake-direct-call-conversation-id',
|
|
|
|
callState: CallState.Ringing,
|
|
|
|
isIncoming: true,
|
|
|
|
isVideoCall: false,
|
|
|
|
hasRemoteVideo: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|