Files
vu/tests/calendar/weekday.test.ts
T
will 37ac31c3f2
Deploy / deploy (push) Successful in 39s
calendar: occurrence engine v2 — real rank thresholds, transfers, collisions
Corrects and completes the occurrence rules, based on a design discussion
plus one concrete data point: St. Anthony Abbot (plain Duplex) was found
outright winning against an ordinary Sunday in the real Monastic 1617
engine, which the old duplex-1-classis-only threshold got wrong.

- FeastClass gains `vigil`, inserted between `simplex` and `semiduplex` —
  one ordering that correctly serves both "does this win against a Sunday"
  (vigil behaves like simplex there) and "which of two saints wins a
  landing-day collision" (vigil beats simplex, loses to semiduplex).
- LiturgicalDay.occurring (a flat OccurringFeast[] that could only ever
  express a losing *sanctoral* candidate) is replaced by `winner:
  DayWinner` + `commemorations: Commemoration[]` — a discriminated list
  that can hold the temporal day itself, one or more sanctoral entries, or
  (not built yet, but the shape already accommodates it) a future octave
  kind.
- commemorations.ts: ordinary Sundays let Duplex+ win outright (Sunday
  commemorated in return), Semiduplex/Vigil transfer elsewhere (too
  substantial a feast to cheapen with a bare commemoration), Simplex stays
  and is commemorated. Privileged Sundays never displace; Duplex-majus+
  commemorated, everything else transfers.
- collision.ts (new): resolves two sanctoral candidates wanting the same
  day (a transfer landing on an already-occupied day, or two native
  saints sharing a date) — duplex > semiduplex > vigil > simplex, loser
  always commemorated, ties favor the native occupant.
- temporal-id.ts (new): maps any date to one of the 52 real Sunday-collect
  ids from the previous commit, so a temporal winner/commemoration can
  actually be looked up, not just labeled "temporal" in the abstract.
- index.ts's resolveDay orchestrates all of it, including the actual
  Monday/Saturday transfer mechanism. Landing on a privileged feria (the
  concrete case: Holy Week, right after Palm Sunday) is explicitly
  deferred rather than guessed at — it needs its own Easter-keyed lookup
  table, the same way the reference engine handles it.

Added the Vigil of St. Lawrence (Aug 9) as real content specifically to
exercise the backward-transfer rule end-to-end: Aug 9, 2026 is a Sunday,
so the vigil transfers cleanly back to Saturday, verified by a new
integration test alongside the unit-level rule and collision tests.
2026-08-10 12:00:01 -04:00

42 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { weekdayOf } from '../../src/calendar/weekday';
import { resolveDay } from '../../src/calendar';
describe('weekdayOf', () => {
it('resolves a known Sunday', () => {
// 2026-08-09 is a Sunday.
expect(weekdayOf('2026-08-09')).toBe('sunday');
});
it('resolves each day of a full week correctly', () => {
const expected = [
['2026-08-09', 'sunday'],
['2026-08-10', 'monday'],
['2026-08-11', 'tuesday'],
['2026-08-12', 'wednesday'],
['2026-08-13', 'thursday'],
['2026-08-14', 'friday'],
['2026-08-15', 'saturday'],
] as const;
for (const [date, weekday] of expected) {
expect(weekdayOf(date)).toBe(weekday);
}
});
it('is not affected by the local timezone offset', () => {
// Regression guard: resolving via `new Date(isoDate)` without pinning to
// UTC would give different weekdays depending on the host's timezone.
expect(weekdayOf('2026-01-01')).toBe('thursday');
});
});
describe('resolveDay', () => {
it('resolves a plain Sunday with no occurring feast', () => {
const day = resolveDay('2026-08-09');
expect(day.date).toBe('2026-08-09');
expect(day.weekday).toBe('sunday');
expect(day.winner).toEqual({ kind: 'temporal', id: 'post-pentecost-11' });
expect(day.commemorations).toEqual([]);
});
});