style: run prettier formatter over src and tests

This commit is contained in:
2026-06-11 20:46:00 +05:30
parent 2389d4f297
commit 6b564a4569
211 changed files with 6134 additions and 4234 deletions
@@ -19,9 +19,14 @@ describe('MigrationRunner', () => {
test('runs migration on missing v5 marker, writes v5 file, backs up v4', () => {
const dir = tmpDir();
fs.writeFileSync(path.join(dir, 'settings.json'), JSON.stringify({ theme: 'light' }));
const r = new MigrationRunner({ dir, transform: (v) => ({ ...v, theme: 'system', 'migration.version': 5 }) });
const r = new MigrationRunner({
dir,
transform: (v) => ({ ...v, theme: 'system', 'migration.version': 5 }),
});
expect(r.run()).toBe('migrated');
expect(JSON.parse(fs.readFileSync(path.join(dir, 'settings.json'), 'utf-8'))['migration.version']).toBe(5);
expect(
JSON.parse(fs.readFileSync(path.join(dir, 'settings.json'), 'utf-8'))['migration.version']
).toBe(5);
expect(fs.existsSync(path.join(dir, 'settings.v4.bak.json'))).toBe(true);
fs.rmSync(dir, { recursive: true });
});
@@ -37,16 +42,28 @@ describe('MigrationRunner', () => {
test('returns failed and writes v5 marker so subsequent runs skip migration', () => {
const dir = tmpDir();
fs.writeFileSync(path.join(dir, 'settings.json'), JSON.stringify({ theme: 'light' }));
const r = new MigrationRunner({ dir, transform: () => { throw new Error('boom'); } });
const r = new MigrationRunner({
dir,
transform: () => {
throw new Error('boom');
},
});
expect(r.run()).toBe('failed');
// v5 marker is written so next launch skips migration
expect(JSON.parse(fs.readFileSync(path.join(dir, 'settings.json'), 'utf-8'))['migration.version']).toBe(5);
expect(
JSON.parse(fs.readFileSync(path.join(dir, 'settings.json'), 'utf-8'))['migration.version']
).toBe(5);
// Original data is preserved (theme: light is still there)
expect(fs.readFileSync(path.join(dir, 'settings.json'), 'utf-8')).toContain('light');
// Backup exists
expect(fs.existsSync(path.join(dir, 'settings.v4.bak.json'))).toBe(true);
// Subsequent run skips
const r2 = new MigrationRunner({ dir, transform: () => { throw new Error('should not be called'); } });
const r2 = new MigrationRunner({
dir,
transform: () => {
throw new Error('should not be called');
},
});
expect(r2.run()).toBe('skipped');
fs.rmSync(dir, { recursive: true });
});