shlink-web-client/test/settings/helpers/index.test.ts

30 lines
876 B
TypeScript
Raw Normal View History

import { fromPartial } from '@total-typescript/shoehorn';
2023-02-18 12:40:37 +03:00
import type { ShlinkState } from '../../../src/container/types';
2023-02-18 13:11:01 +03:00
import { migrateDeprecatedSettings } from '../../../src/settings/helpers';
describe('settings-helpers', () => {
describe('migrateDeprecatedSettings', () => {
it('returns object as is if settings are not set', () => {
expect(migrateDeprecatedSettings({})).toEqual({});
});
it('updates settings as expected', () => {
const state = fromPartial<ShlinkState>({
settings: {
visits: {
defaultInterval: 'last180days' as any,
},
},
});
expect(migrateDeprecatedSettings(state)).toEqual(expect.objectContaining({
settings: expect.objectContaining({
visits: {
defaultInterval: 'last180Days',
},
}),
}));
});
});
});