mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
de157cb87b
Server (172 tests): - journeyService unit tests (87 tests): CRUD, access control, sync, photos, contributors - journeyShareService unit tests (20 tests): share links, token validation, public access - journey integration tests (45 tests): all API routes, auth, permissions, edge cases - Test helpers: journey factories, RESET_TABLES updated Client (340+ tests): - journeyStore tests (15 tests): all store actions and state management - JourneyPage tests (20 tests): frontpage, create flow, suggestions, navigation - JourneyDetailPage tests (94 tests): all sub-components, entry editor, settings, share links, contributors, gallery, map, trip linking - JourneyPublicPage tests (18 tests): public view, tabs, restricted access - JourneyBookPDF tests (6 tests): PDF generation - BottomNav tests (9 tests): profile sheet, navigation - PhotoLightbox tests (8 tests): keyboard nav, counter - JourneyMap tests (12 tests): markers, polylines, zoom - Component tests: moodConfig, stripMarkdown, MarkdownToolbar, JournalBody, MobileTopHeader - DashboardPage tests (32 tests): spotlight card, quick actions, widget settings SonarQube: exclude unused MemoriesPanel from coverage (dead code, moved to Journey)
70 lines
2.4 KiB
TypeScript
70 lines
2.4 KiB
TypeScript
// FE-COMP-MOOD-001 to FE-COMP-MOOD-005
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
import { MOODS, WEATHERS, getMood, moodColor, tagColors, TAG_STYLES, MOOD_DEFAULT_COLOR } from './moodConfig';
|
|
|
|
describe('moodConfig', () => {
|
|
it('FE-COMP-MOOD-001: MOODS contains all five mood definitions', () => {
|
|
const ids = MOODS.map(m => m.id);
|
|
expect(ids).toEqual(['amazing', 'good', 'neutral', 'tired', 'rough']);
|
|
expect(MOODS).toHaveLength(5);
|
|
});
|
|
|
|
it('FE-COMP-MOOD-002: every mood has valid hex color and css var', () => {
|
|
for (const mood of MOODS) {
|
|
expect(mood.color).toMatch(/^#[0-9A-Fa-f]{6}$/);
|
|
expect(mood.cssVar).toMatch(/^var\(--mood-.+\)$/);
|
|
expect(mood.icon).toBeDefined();
|
|
expect(mood.label).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
it('FE-COMP-MOOD-003: getMood returns correct mood or undefined', () => {
|
|
expect(getMood('amazing')?.id).toBe('amazing');
|
|
expect(getMood('rough')?.color).toBe('#9B8EC4');
|
|
expect(getMood('nonexistent')).toBeUndefined();
|
|
expect(getMood(null)).toBeUndefined();
|
|
expect(getMood(undefined)).toBeUndefined();
|
|
});
|
|
|
|
it('FE-COMP-MOOD-004: moodColor returns css var or fallback', () => {
|
|
expect(moodColor('good')).toBe('var(--mood-good)');
|
|
expect(moodColor(null)).toBe('var(--journal-faint)');
|
|
expect(moodColor('unknown')).toBe('var(--journal-faint)');
|
|
});
|
|
|
|
it('FE-COMP-MOOD-005: WEATHERS contains all eight entries with icons', () => {
|
|
expect(WEATHERS).toHaveLength(8);
|
|
const ids = WEATHERS.map(w => w.id);
|
|
expect(ids).toContain('sunny');
|
|
expect(ids).toContain('snowy');
|
|
expect(ids).toContain('stormy');
|
|
for (const w of WEATHERS) {
|
|
expect(w.icon).toBeDefined();
|
|
expect(w.label).toBeTruthy();
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('tagColors', () => {
|
|
it('FE-COMP-MOOD-006: returns known tag colors for light and dark mode', () => {
|
|
const light = tagColors('hidden gem', false);
|
|
expect(light.bg).toBe('#dcfce7');
|
|
expect(light.fg).toBe('#166534');
|
|
|
|
const dark = tagColors('hidden gem', true);
|
|
expect(dark.bg).toBe('rgba(22,101,52,0.2)');
|
|
expect(dark.fg).toBe('#86efac');
|
|
});
|
|
|
|
it('FE-COMP-MOOD-007: returns fallback colors for unknown tags', () => {
|
|
const light = tagColors('random tag', false);
|
|
expect(light.bg).toBe('rgba(0,0,0,0.05)');
|
|
expect(light.fg).toBe('#374151');
|
|
|
|
const dark = tagColors('random tag', true);
|
|
expect(dark.bg).toBe('rgba(255,255,255,0.07)');
|
|
expect(dark.fg).toBe('#a1a1aa');
|
|
});
|
|
});
|