feat: add org_config loader with caching and defaults
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseOrgConfig, type OrgConfig } from '$lib/server/config';
|
||||
|
||||
describe('config', () => {
|
||||
it('parses org config rows into structured object', () => {
|
||||
const rows = [
|
||||
{ key: 'branding', value: { primaryColor: '#0d9488', accentColor: '#f59e0b', logoUrl: '' } },
|
||||
{ key: 'org_info', value: { name: 'Test Rescue', city: 'Sioux Falls', state: 'SD' } },
|
||||
{ key: 'locale', value: { language: 'en', currency: 'USD', dateFormat: 'MM/DD/YYYY' } }
|
||||
];
|
||||
|
||||
const config = parseOrgConfig(rows);
|
||||
expect(config.branding.primaryColor).toBe('#0d9488');
|
||||
expect(config.orgInfo.name).toBe('Test Rescue');
|
||||
expect(config.locale.language).toBe('en');
|
||||
});
|
||||
|
||||
it('provides defaults for missing keys', () => {
|
||||
const config = parseOrgConfig([]);
|
||||
expect(config.branding.primaryColor).toBe('#0d9488');
|
||||
expect(config.orgInfo.name).toBe('My Rescue');
|
||||
expect(config.locale.language).toBe('en');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user