2020-09-09 20:16:04 +03:00
|
|
|
import reducer, { SET_REAL_TIME_UPDATES, 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 };
|
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', () => {
|
2020-08-25 20:41:48 +03:00
|
|
|
expect(reducer(undefined, { type: SET_REAL_TIME_UPDATES, realTimeUpdates })).toEqual({ realTimeUpdates });
|
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
|
|
|
|
2020-04-26 20:04:17 +03:00
|
|
|
expect(result).toEqual({ type: SET_REAL_TIME_UPDATES, 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);
|
|
|
|
|
|
|
|
expect(result).toEqual({ type: SET_REAL_TIME_UPDATES, realTimeUpdates: { interval } });
|
|
|
|
});
|
|
|
|
});
|
2020-04-25 11:22:17 +03:00
|
|
|
});
|