2022-01-14 21:00:04 +00:00
|
|
|
import { addSettings, clearSettings, updateSettings } from '../actions/settings';
|
|
|
|
import { mockedStore } from './mockedStore';
|
2022-03-02 14:49:43 +00:00
|
|
|
import { initialState, TSettingsState } from './settings';
|
2022-01-14 21:00:04 +00:00
|
|
|
|
|
|
|
describe('test settings reducer', () => {
|
|
|
|
it('should return initial state', () => {
|
|
|
|
const state = mockedStore.getState().settings;
|
|
|
|
expect(state).toEqual(initialState);
|
|
|
|
});
|
|
|
|
|
2022-03-02 14:49:43 +00:00
|
|
|
const settings: TSettingsState = {
|
|
|
|
API_Use_REST_For_DDP_Calls: true,
|
|
|
|
FileUpload_MaxFileSize: 600857600,
|
|
|
|
Jitsi_URL_Room_Prefix: 'RocketChat'
|
|
|
|
};
|
2022-01-14 21:00:04 +00:00
|
|
|
|
|
|
|
it('should return modified store after call addSettings action', () => {
|
|
|
|
mockedStore.dispatch(addSettings(settings));
|
|
|
|
const state = mockedStore.getState().settings;
|
|
|
|
expect(state).toEqual(settings);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return correctly settings after call updateSettings action', () => {
|
|
|
|
const id = 'Jitsi_URL_Room_Prefix';
|
|
|
|
mockedStore.dispatch(updateSettings(id, 'ChatRocket'));
|
|
|
|
const state = mockedStore.getState().settings;
|
|
|
|
expect(state[id]).toEqual('ChatRocket');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return initial state after clearSettings', () => {
|
|
|
|
mockedStore.dispatch(clearSettings());
|
|
|
|
const state = mockedStore.getState().settings;
|
|
|
|
expect(state).toEqual({});
|
|
|
|
});
|
|
|
|
});
|