feat(layout): finalize p01 and p02 changes
Complete UI foundation and app layout implementation, stabilize container health checks, and archive both OpenSpec changes after verification.
This commit is contained in:
37
frontend/tests/component/month-selector.test.ts
Normal file
37
frontend/tests/component/month-selector.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import MonthSelector, {
|
||||
formatMonth,
|
||||
generateMonthOptions
|
||||
} from '../../src/lib/components/layout/MonthSelector.svelte';
|
||||
import { selectedPeriod, setPeriod } from '../../src/lib/stores/period';
|
||||
|
||||
function getStoreValue<T>(store: { subscribe: (run: (value: T) => void) => () => void }): T {
|
||||
let value!: T;
|
||||
const unsubscribe = store.subscribe((current) => {
|
||||
value = current;
|
||||
});
|
||||
unsubscribe();
|
||||
return value;
|
||||
}
|
||||
|
||||
describe('MonthSelector component', () => {
|
||||
it('exports a component module', () => {
|
||||
expect(MonthSelector).toBeDefined();
|
||||
});
|
||||
|
||||
it('formats month labels', () => {
|
||||
expect(formatMonth('2026-02')).toBe('Feb 2026');
|
||||
});
|
||||
|
||||
it('builds +/- 6 month options', () => {
|
||||
const options = generateMonthOptions(new Date(2026, 1, 1));
|
||||
expect(options).toHaveLength(13);
|
||||
expect(options[0]).toBe('2025-08');
|
||||
expect(options[12]).toBe('2026-08');
|
||||
});
|
||||
|
||||
it('selection updates period store', () => {
|
||||
setPeriod('2026-02');
|
||||
expect(getStoreValue(selectedPeriod)).toBe('2026-02');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user