Mechanical reformat — no logic changes. 398 files changed, 19125 insertions(+), 16457 deletions(-). Prettier 3.8.4 with .prettierrc (singleQuote:true, semi:true, tabWidth:2, trailingComma:all, printWidth:100). Isolated per D-13-08 for reviewability.
51 lines
2.1 KiB
TypeScript
51 lines
2.1 KiB
TypeScript
/**
|
|
* RED test stubs for calendarConfig — Wave 0 state.
|
|
*
|
|
* These tests encode the contracts for calendarConfig.ts.
|
|
* The tests reference the not-yet-built module apps/pwa/src/lib/calendarConfig.ts.
|
|
*
|
|
* Contracts locked here:
|
|
* 1. WEEK_START_DAY === 0 (JS/date-fns Sunday convention) → Schedule-X firstDayOfWeek === 7
|
|
* (Temporal convention: 7 = Sunday, not 0)
|
|
* Passing 0 would silently default to Monday in Schedule-X v4.
|
|
*/
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
// Not yet built — import will fail (RED state) until Plan 03 implements calendarConfig.ts
|
|
import { WEEK_START_DAY, buildCalendarConfig } from './calendarConfig.js';
|
|
|
|
describe('calendarConfig — RED stubs (Wave 0)', () => {
|
|
it('WEEK_START_DAY constant equals 0 (Sunday in JS/date-fns convention)', () => {
|
|
// The project uses 0 = Sunday (JS/date-fns convention).
|
|
// This constant is translated to 7 before passing to Schedule-X.
|
|
expect(WEEK_START_DAY).toBe(0);
|
|
});
|
|
|
|
it('WEEK_START_DAY=0 translates to Schedule-X firstDayOfWeek === 7', () => {
|
|
// Schedule-X v4 uses Temporal numbering: 1=Mon, 7=Sun.
|
|
// WEEK_START_DAY=0 (JS Sunday) must become 7 (Temporal Sunday).
|
|
// This avoids the Pitfall 1 silent failure where weeks start on Monday.
|
|
const config = buildCalendarConfig([]);
|
|
expect(config.firstDayOfWeek).toBe(7);
|
|
});
|
|
|
|
it('buildCalendarConfig includes shared-family calendar with id "shared"', () => {
|
|
const config = buildCalendarConfig([]);
|
|
expect(config.calendars).toHaveProperty('shared');
|
|
expect(config.calendars['shared'].colorName).toBe('shared');
|
|
});
|
|
|
|
it('buildCalendarConfig includes per-member calendars keyed by String(userId)', () => {
|
|
const members = [
|
|
{ id: '1', name: 'Lucas', color: '#4A90D9' },
|
|
{ id: '2', name: 'Spouse', color: '#E8734A' },
|
|
];
|
|
const config = buildCalendarConfig(members);
|
|
expect(config.calendars).toHaveProperty('1');
|
|
expect(config.calendars).toHaveProperty('2');
|
|
expect(config.calendars['1'].lightColors.main).toBe('#4A90D9');
|
|
expect(config.calendars['2'].lightColors.main).toBe('#E8734A');
|
|
});
|
|
});
|