Complete UI foundation and app layout implementation, stabilize container health checks, and archive both OpenSpec changes after verification.
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
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');
|
|
});
|
|
});
|