mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-12 20:06:57 +02:00
Adds src/lib/utils/theme.svelte.ts with applyTheme() (sets data-theme attribute and meta theme-color) and getIsDarkMode(). Uses a plain variable instead of $state since Vitest's node environment does not compile Svelte 5 runes in .svelte.ts files. Adds jsdom dev dependency and $app/environment alias in vitest config to support DOM-level unit tests; fixes preferences.test.ts to include the theme default added in Task 2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
1014 B
TypeScript
28 lines
1014 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { DEFAULT_PREFERENCES, BOOLEAN_PREF_KEYS } from '$lib/types/preferences.js';
|
|
|
|
describe('preferences defaults', () => {
|
|
it('should have correct default values', () => {
|
|
expect(DEFAULT_PREFERENCES).toEqual({
|
|
theme: 'system',
|
|
defaultNoteMode: 'richtext',
|
|
defaultNoteColor: 'default',
|
|
hideFooter: false,
|
|
sidebarDefaultState: 'open',
|
|
notifyOnShare: true,
|
|
notifyOnCollabRemoved: true,
|
|
notifyOnNoteDeleted: true
|
|
});
|
|
});
|
|
|
|
it('should identify boolean preference keys', () => {
|
|
expect(BOOLEAN_PREF_KEYS.has('hideFooter')).toBe(true);
|
|
expect(BOOLEAN_PREF_KEYS.has('notifyOnShare')).toBe(true);
|
|
expect(BOOLEAN_PREF_KEYS.has('notifyOnCollabRemoved')).toBe(true);
|
|
expect(BOOLEAN_PREF_KEYS.has('notifyOnNoteDeleted')).toBe(true);
|
|
expect(BOOLEAN_PREF_KEYS.has('defaultNoteMode')).toBe(false);
|
|
expect(BOOLEAN_PREF_KEYS.has('defaultNoteColor')).toBe(false);
|
|
expect(BOOLEAN_PREF_KEYS.has('sidebarDefaultState')).toBe(false);
|
|
});
|
|
});
|