verdnatura-chat/app/reducers/settings.test.ts

32 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-02-28 18:00:47 +00:00
import { addSettings, clearSettings, updateSettings } from '../actions/settings';
import { mockedStore } from './mockedStore';
import { initialState } from './settings';
describe('test settings reducer', () => {
it('should return initial state', () => {
const state = mockedStore.getState().settings;
expect(state).toEqual(initialState);
});
const settings = { API_Use_REST_For_DDP_Calls: true, FileUpload_MaxFileSize: 600857600, Jitsi_URL_Room_Prefix: 'RocketChat' };
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({});
});
});