2021-02-14 15:23:42 +03:00
|
|
|
import reducer, { SET_SETTINGS, toggleRealTimeUpdates, setRealTimeUpdatesInterval } from '../../../src/settings/reducers/settings';
|
2020-04-25 11:22:17 +03:00
|
|
|
|
2020-04-26 14:00:23 +03:00
|
|
|
describe('settingsReducer', () => {
|
|
|
|
const realTimeUpdates = { enabled: true };
|
2021-02-14 15:23:42 +03:00
|
|
|
const shortUrlCreation = { validateUrls: false };
|
|
|
|
const settings = { realTimeUpdates, shortUrlCreation };
|
2020-04-25 11:22:17 +03:00
|
|
|
|
|
|
|
describe('reducer', () => {
|
2020-04-26 20:04:17 +03:00
|
|
|
it('returns realTimeUpdates when action is SET_REAL_TIME_UPDATES', () => {
|
2021-02-14 15:23:42 +03:00
|
|
|
expect(reducer(undefined, { type: SET_SETTINGS, realTimeUpdates })).toEqual(settings);
|
2020-04-25 11:22:17 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-09-09 20:16:04 +03:00
|
|
|
describe('toggleRealTimeUpdates', () => {
|
2020-04-25 11:22:17 +03:00
|
|
|
it.each([[ true ], [ false ]])('updates settings with provided value and then loads updates again', (enabled) => {
|
2020-09-09 20:16:04 +03:00
|
|
|
const result = toggleRealTimeUpdates(enabled);
|
2020-04-25 11:22:17 +03:00
|
|
|
|
2021-02-14 15:23:42 +03:00
|
|
|
expect(result).toEqual({ type: SET_SETTINGS, realTimeUpdates: { enabled } });
|
2020-04-25 11:22:17 +03:00
|
|
|
});
|
|
|
|
});
|
2020-09-09 20:16:04 +03:00
|
|
|
|
|
|
|
describe('setRealTimeUpdatesInterval', () => {
|
|
|
|
it.each([[ 0 ], [ 1 ], [ 2 ], [ 10 ]])('updates settings with provided value and then loads updates again', (interval) => {
|
|
|
|
const result = setRealTimeUpdatesInterval(interval);
|
|
|
|
|
2021-02-14 15:23:42 +03:00
|
|
|
expect(result).toEqual({ type: SET_SETTINGS, realTimeUpdates: { interval } });
|
2020-09-09 20:16:04 +03:00
|
|
|
});
|
|
|
|
});
|
2020-04-25 11:22:17 +03:00
|
|
|
});
|