2021-12-23 19:59:18 +03:00
|
|
|
import { Mock } from 'ts-mockery';
|
|
|
|
import { migrateDeprecatedSettings } from '../../../src/settings/helpers';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { ShlinkState } from '../../../src/container/types';
|
2021-12-23 19:59:18 +03:00
|
|
|
|
|
|
|
describe('settings-helpers', () => {
|
|
|
|
describe('migrateDeprecatedSettings', () => {
|
2022-01-01 11:40:26 +03:00
|
|
|
it('returns object as is if settings are not set', () => {
|
|
|
|
expect(migrateDeprecatedSettings({})).toEqual({});
|
|
|
|
});
|
|
|
|
|
2021-12-23 19:59:18 +03:00
|
|
|
it('updates settings as expected', () => {
|
|
|
|
const state = Mock.of<ShlinkState>({
|
|
|
|
settings: {
|
|
|
|
visits: {
|
|
|
|
defaultInterval: 'last180days' as any,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(migrateDeprecatedSettings(state)).toEqual(expect.objectContaining({
|
|
|
|
settings: expect.objectContaining({
|
|
|
|
visits: {
|
|
|
|
defaultInterval: 'last180Days',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|