refactor: align export, settings and database with the VidIQ record model

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
IgorVolochay
2026-10-25 12:07:24 +03:00
co-authored by Claude Sonnet 5.5
parent 6de9e9656c
commit 1cf5270704
5 changed files with 40 additions and 57 deletions
+5 -9
View File
@@ -3,17 +3,13 @@ import assert from 'node:assert/strict';
import { DEFAULT_SETTINGS, normalizeSettings } from '../src/lib/storage.js';
test('normalizeSettings falls back to defaults for missing input', () => {
assert.deepEqual(DEFAULT_SETTINGS, { threshold: 5, minViews: 10000 });
assert.deepEqual(normalizeSettings(), DEFAULT_SETTINGS);
assert.deepEqual(normalizeSettings({}), DEFAULT_SETTINGS);
assert.deepEqual(DEFAULT_SETTINGS, { apiKey: '', threshold: 5, minViews: 10000 });
});
test('normalizeSettings trims the key and coerces numeric strings', () => {
assert.deepEqual(normalizeSettings({ apiKey: ' abc123 ', threshold: '7.5', minViews: '20000' }), {
apiKey: 'abc123',
threshold: 7.5,
minViews: 20000,
});
test('normalizeSettings coerces numeric strings', () => {
assert.deepEqual(normalizeSettings({ threshold: '7.5', minViews: '20000' }), { threshold: 7.5, minViews: 20000 });
});
test('normalizeSettings replaces invalid thresholds with the default', () => {
@@ -30,6 +26,6 @@ test('normalizeSettings replaces invalid minViews with the default and floors de
assert.equal(normalizeSettings({ minViews: 0 }).minViews, 0);
});
test('normalizeSettings ignores a non-string key', () => {
assert.equal(normalizeSettings({ apiKey: 12345 }).apiKey, '');
test('normalizeSettings drops fields it does not know (the old apiKey)', () => {
assert.deepEqual(normalizeSettings({ apiKey: 'secret', threshold: 6 }), { threshold: 6, minViews: 10000 });
});