Rocket.Chat.ReactNative/app/reducers/videoConf.test.ts

64 lines
2.1 KiB
TypeScript
Raw Normal View History

feat: Add caller and ringer to video conf calls (#5046) * add expo camera and use camera on call init action sheet * fix permissions * set colors when calling * update @react-native-community/hooks lib * move to useWindowDimensions * create action to handle video-conf calls * create videoConf reducer * add typed-redux-saga lib * fix return * change videoConf saga to TS * fix TS target * update action and types * create actionSheetRef * add notifyUser api * export video conf types * add action prop * use new reducer prop * add videoConferenceCancel and add allowRinging to videoConferenceStart * temp-patch * add locales * add handler to videoconf message * fix rest types * add message types * path to remove component from dom * remove notification when is videoconf * create sound hook * create dots loader * update call translation * the end is near * move to confirmed * better code reading * fix call type * fix tests * update podfile * wip * fix call order * move colors * move to jsx * fix colors * add pt-br * remove patch and point * fix colors * fix expo camera * move to style * remove unused styles * update types and style * wip * rename IncomingCallComponent * add custom notification * wip * fix naming * fix styles * fix import * fix styles * change colors * fixa ringing * fix import * organize * fix sizes * use realName * fix spacing * fix icon size * fix header gap * changeColor * fix safeArea * set calling only on direct calls * change ringer to be a component * cancel call on swipe * remove join on direct calls * add props * update package
2023-07-04 00:03:39 +00:00
import { clearVideoConfCalls, removeVideoConfCall, setVideoConfCall, setCalling } from '../actions/videoConf';
import { mockedStore } from './mockedStore';
import { initialState, ICallInfo } from './videoConf';
describe('test videoConf reducer', () => {
it('should return initial state', () => {
const state = mockedStore.getState().videoConf;
expect(state).toEqual(initialState);
});
const call1: ICallInfo = {
callId: '123',
rid: '123',
action: 'accepted',
uid: '123'
};
const call2: ICallInfo = {
callId: '321',
rid: '321',
action: 'accepted',
uid: '321'
};
it('should return call1 after call addSettings action with call1 as parameter', () => {
mockedStore.dispatch(setVideoConfCall(call1));
const state = mockedStore.getState().videoConf;
const call = state.calls.find(c => c.callId === call1.callId);
expect(call).toEqual(call1);
});
it('should return call2 after call addSettings action with call2 as parameter', () => {
mockedStore.dispatch(setVideoConfCall(call2));
const state = mockedStore.getState().videoConf;
const call = state.calls.find(c => c.callId === call2.callId);
expect(call).toEqual(call2);
});
it('should remove call1 after call removeVideoConfCall action with call1 as parameter', () => {
mockedStore.dispatch(removeVideoConfCall(call1));
const state = mockedStore.getState().videoConf;
const call = state.calls.find(c => c.callId === call1.callId);
expect(call).toEqual(undefined);
});
it('should set calling true after call setCalling action with true as parameter', () => {
mockedStore.dispatch(setCalling(true));
const state = mockedStore.getState().videoConf;
expect(state.calling).toEqual(true);
});
it('should set calling false after call setCalling action with false as parameter', () => {
mockedStore.dispatch(setCalling(false));
const state = mockedStore.getState().videoConf;
expect(state.calling).toEqual(false);
});
it('should return initial state after clearSettings', () => {
mockedStore.dispatch(clearVideoConfCalls());
const state = mockedStore.getState().videoConf;
expect(state).toEqual(initialState);
});
});