fb7b4eefc1
Build & Push / Build & Push Docker Image (push) Failing after 2m50s
Test / Type Check (all packages) (push) Failing after 55s
Test / API Unit Tests (push) Has been skipped
Test / Homepage Unit Tests (push) Has been skipped
Test / Carplace Unit Tests (push) Has been skipped
Test / Admin Unit Tests (push) Has been skipped
Test / Dashboard Unit Tests (push) Has been skipped
Test / API Integration Tests (push) Has been skipped
25 lines
993 B
TypeScript
25 lines
993 B
TypeScript
import { currentThemePreference } from '@/lib/theme/client';
|
|
import { isThemePreference, resolveTheme, serverResolvedTheme } from '@/lib/theme/config';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
describe('theme foundations', () => {
|
|
it('accepts only approved preferences', () => {
|
|
expect(isThemePreference('light')).toBe(true);
|
|
expect(isThemePreference('dark')).toBe(true);
|
|
expect(isThemePreference('system')).toBe(true);
|
|
expect(isThemePreference('sepia')).toBe(false);
|
|
});
|
|
|
|
it('keeps preference and resolved theme separate', () => {
|
|
expect(resolveTheme('system', true)).toBe('dark');
|
|
expect(resolveTheme('system', false)).toBe('light');
|
|
expect(resolveTheme('light', true)).toBe('light');
|
|
expect(serverResolvedTheme('system')).toBe('light');
|
|
});
|
|
|
|
it('defaults client theme preference to dark when no choice exists', () => {
|
|
delete document.documentElement.dataset.themePreference;
|
|
expect(currentThemePreference()).toBe('dark');
|
|
});
|
|
});
|