2024-05-20 21:03:50 +03:00
|
|
|
import type { Settings } from '@shlinkio/shlink-web-component/settings';
|
|
|
|
import { fromPartial } from '@total-typescript/shoehorn';
|
|
|
|
import { DEFAULT_SHORT_URLS_ORDERING, setSettings, settingsReducer } 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 };
|
2024-05-20 21:03:50 +03:00
|
|
|
const ui = { theme: 'light' as const };
|
|
|
|
const visits = { defaultInterval: 'last30Days' as const };
|
2021-12-24 16:15:28 +03:00
|
|
|
const shortUrlsList = { defaultOrdering: DEFAULT_SHORT_URLS_ORDERING };
|
2024-05-20 21:03:50 +03:00
|
|
|
const settings = fromPartial<Settings>({ realTimeUpdates, shortUrlCreation, ui, visits, shortUrlsList });
|
2020-04-25 11:22:17 +03:00
|
|
|
|
|
|
|
describe('reducer', () => {
|
2024-05-20 21:03:50 +03:00
|
|
|
it('can update settings', () => {
|
|
|
|
expect(settingsReducer(undefined, setSettings(settings))).toEqual(settings);
|
2020-04-25 11:22:17 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-05-20 21:03:50 +03:00
|
|
|
describe('setSettings', () => {
|
|
|
|
it('creates action to set settings', () => {
|
|
|
|
const { payload } = setSettings(settings);
|
|
|
|
expect(payload).toEqual(settings);
|
2021-12-24 16:15:28 +03:00
|
|
|
});
|
|
|
|
});
|
2020-04-25 11:22:17 +03:00
|
|
|
});
|