2024-05-20 20:03:50 +02: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 10:22:17 +02:00
|
|
|
|
2020-04-26 13:00:23 +02:00
|
|
|
describe('settingsReducer', () => {
|
|
|
|
const realTimeUpdates = { enabled: true };
|
2021-02-14 13:23:42 +01:00
|
|
|
const shortUrlCreation = { validateUrls: false };
|
2024-05-20 20:03:50 +02:00
|
|
|
const ui = { theme: 'light' as const };
|
|
|
|
const visits = { defaultInterval: 'last30Days' as const };
|
2021-12-24 14:15:28 +01:00
|
|
|
const shortUrlsList = { defaultOrdering: DEFAULT_SHORT_URLS_ORDERING };
|
2024-05-20 20:03:50 +02:00
|
|
|
const settings = fromPartial<Settings>({ realTimeUpdates, shortUrlCreation, ui, visits, shortUrlsList });
|
2020-04-25 10:22:17 +02:00
|
|
|
|
|
|
|
describe('reducer', () => {
|
2024-05-20 20:03:50 +02:00
|
|
|
it('can update settings', () => {
|
|
|
|
expect(settingsReducer(undefined, setSettings(settings))).toEqual(settings);
|
2020-04-25 10:22:17 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-05-20 20:03:50 +02:00
|
|
|
describe('setSettings', () => {
|
|
|
|
it('creates action to set settings', () => {
|
|
|
|
const { payload } = setSettings(settings);
|
|
|
|
expect(payload).toEqual(settings);
|
2021-12-24 14:15:28 +01:00
|
|
|
});
|
|
|
|
});
|
2020-04-25 10:22:17 +02:00
|
|
|
});
|