Wire guest branding theme
This commit is contained in:
56
resources/js/admin/lib/__tests__/brandingForm.test.ts
Normal file
56
resources/js/admin/lib/__tests__/brandingForm.test.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { extractBrandingForm } from '../brandingForm';
|
||||
|
||||
const defaults = {
|
||||
primary: '#111111',
|
||||
accent: '#222222',
|
||||
background: '#ffffff',
|
||||
surface: '#f0f0f0',
|
||||
mode: 'auto' as const,
|
||||
};
|
||||
|
||||
describe('extractBrandingForm', () => {
|
||||
it('prefers palette values when available', () => {
|
||||
const settings = {
|
||||
branding: {
|
||||
palette: {
|
||||
primary: '#aa0000',
|
||||
secondary: '#00aa00',
|
||||
background: '#000000',
|
||||
surface: '#111111',
|
||||
},
|
||||
primary_color: '#bbbbbb',
|
||||
secondary_color: '#cccccc',
|
||||
background_color: '#dddddd',
|
||||
surface_color: '#eeeeee',
|
||||
mode: 'dark',
|
||||
},
|
||||
};
|
||||
|
||||
const result = extractBrandingForm(settings, defaults);
|
||||
|
||||
expect(result.primary).toBe('#aa0000');
|
||||
expect(result.accent).toBe('#00aa00');
|
||||
expect(result.background).toBe('#000000');
|
||||
expect(result.surface).toBe('#111111');
|
||||
expect(result.mode).toBe('dark');
|
||||
});
|
||||
|
||||
it('falls back to legacy keys and defaults', () => {
|
||||
const settings = {
|
||||
branding: {
|
||||
accent_color: '#123456',
|
||||
background_color: '#abcdef',
|
||||
mode: 'light',
|
||||
},
|
||||
};
|
||||
|
||||
const result = extractBrandingForm(settings, defaults);
|
||||
|
||||
expect(result.primary).toBe(defaults.primary);
|
||||
expect(result.accent).toBe('#123456');
|
||||
expect(result.background).toBe('#abcdef');
|
||||
expect(result.surface).toBe('#abcdef');
|
||||
expect(result.mode).toBe('light');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user