mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
test: add migration tests for moving settings from MiscConfig to TasksConfig
This commit is contained in:
parent
92d7d4aafe
commit
aedab573a0
1 changed files with 72 additions and 0 deletions
|
|
@ -0,0 +1,72 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import { MIGRATIONS } from '../../src/migrations';
|
||||
|
||||
describe('Migrate MiscConfig to TasksConfig', () => {
|
||||
const migration = MIGRATIONS.find((m) => m.fromVersion === 16 && m.toVersion === 17);
|
||||
|
||||
if (!migration) {
|
||||
throw new Error('Migration for version 16 to 17 not found');
|
||||
}
|
||||
|
||||
it('should migrate settings from misc to tasks', () => {
|
||||
const initialState = {
|
||||
misc: {
|
||||
isConfirmBeforeTaskDelete: true,
|
||||
isAutoAddWorkedOnToToday: true,
|
||||
isAutMarkParentAsDone: false,
|
||||
isTrayShowCurrentTask: true,
|
||||
defaultProjectId: 'project_1',
|
||||
taskNotesTpl: 'Template',
|
||||
},
|
||||
tasks: {},
|
||||
};
|
||||
|
||||
const migratedState = migration.migrateState(initialState) as {
|
||||
misc: Record<string, unknown>;
|
||||
tasks: Record<string, unknown>;
|
||||
};
|
||||
|
||||
expect(migratedState.tasks).toEqual({
|
||||
isConfirmBeforeTaskDelete: true,
|
||||
isAutoAddWorkedOnToToday: true,
|
||||
isAutoMarkParentAsDone: false,
|
||||
isTrayShowCurrentTask: true,
|
||||
defaultProjectId: 'project_1',
|
||||
notesTemplate: 'Template',
|
||||
});
|
||||
|
||||
expect(migratedState.misc).toEqual({});
|
||||
});
|
||||
|
||||
it('should not modify state if misc is empty', () => {
|
||||
const initialState = {
|
||||
misc: {},
|
||||
tasks: {},
|
||||
};
|
||||
|
||||
const migratedState = migration.migrateState(initialState) as {
|
||||
misc: Record<string, unknown>;
|
||||
tasks: Record<string, unknown>;
|
||||
};
|
||||
|
||||
expect(migratedState).toEqual(initialState);
|
||||
});
|
||||
|
||||
it('should not modify state if tasks already migrated', () => {
|
||||
const initialState = {
|
||||
misc: {
|
||||
isConfirmBeforeTaskDelete: true,
|
||||
},
|
||||
tasks: {
|
||||
isConfirmBeforeTaskDelete: true,
|
||||
},
|
||||
};
|
||||
|
||||
const migratedState = migration.migrateState(initialState) as {
|
||||
misc: Record<string, unknown>;
|
||||
tasks: Record<string, unknown>;
|
||||
};
|
||||
|
||||
expect(migratedState).toEqual(initialState);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue