Files
vu/tests/calendar/commemorations.test.ts
T
will effe2b1333
Deploy / deploy (push) Successful in 41s
calendar: split privileged-feria into two real precedence tiers
A plain Duplex saint was losing to any privileged feria (Ember days
included) since the occurrence engine only let duplex-1-classis+ get
even a commemoration there. Verified this was wrong: St. Gregory the
Great, plain Duplex, outright wins against a Lenten Ember Saturday in
the real Monastic 1617 engine.

Splits TemporalCategory's single privileged-feria into privileged-feria
(the lesser tier — Lent's Ember days, verified — now behaves like an
ordinary Sunday: Duplex+ wins outright) and privileged-feria-major (Ash
Wednesday, Holy Week, the Easter Octave, verified via St. Mark only ever
being commemorated there, never winning — behaves like privileged-
Sunday). Everywhere else the old single category was ambiguous
(Pentecost's own Ember days/Vigil/Octave, the Vigil of Christmas)
defaults to the stricter major tier pending verification.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 15:51:09 -04:00

136 lines
6.7 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { decideOccurrence, compareFeastClass, isAtLeast } from '../../src/calendar/commemorations';
import type { SanctoralIdentity } from '../../src/calendar/types';
function saint(rank: SanctoralIdentity['rank']): SanctoralIdentity {
return { id: 'x', name: 'St. Ereden', rank };
}
describe('compareFeastClass / isAtLeast', () => {
it('orders the seven ranks low to high, with vigil between simplex and semiduplex', () => {
expect(compareFeastClass('simplex', 'vigil')).toBeLessThan(0);
expect(compareFeastClass('vigil', 'semiduplex')).toBeLessThan(0);
expect(compareFeastClass('semiduplex', 'duplex')).toBeLessThan(0);
expect(compareFeastClass('duplex-1-classis', 'simplex')).toBeGreaterThan(0);
expect(compareFeastClass('duplex', 'duplex')).toBe(0);
});
it('isAtLeast is inclusive of the threshold itself', () => {
expect(isAtLeast('duplex-majus', 'duplex-majus')).toBe(true);
expect(isAtLeast('duplex', 'duplex-majus')).toBe(false);
});
});
describe('decideOccurrence — no candidate', () => {
it('temporal wins trivially when nothing is assigned to the date', () => {
expect(decideOccurrence('ordinary-feria', 'some-feria-id', null)).toEqual({
winner: { kind: 'temporal', id: 'some-feria-id' },
commemorations: [],
});
});
});
describe('decideOccurrence — ordinary-feria', () => {
it('always yields to any real feast, uncommemorated, whatever its rank', () => {
for (const rank of ['simplex', 'vigil', 'semiduplex', 'duplex', 'duplex-1-classis'] as const) {
const result = decideOccurrence('ordinary-feria', 'id', saint(rank));
expect(result.winner).toEqual({ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank });
expect(result.commemorations).toEqual([]);
expect(result.transfer).toBeUndefined();
}
});
});
describe('decideOccurrence — privileged-feria', () => {
it('behaves exactly like an ordinary Sunday — duplex or higher wins outright, the feria is commemorated in return', () => {
// Verified: St. Gregory the Great, plain Duplex, outright wins against
// a Lenten Ember Saturday in the real Monastic 1617 engine.
const result = decideOccurrence('privileged-feria', 'id', saint('duplex'));
expect(result.winner).toEqual({ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank: 'duplex' });
expect(result.commemorations).toEqual([{ kind: 'temporal', id: 'id' }]);
});
it('simplex stays and is commemorated, not transferred', () => {
const result = decideOccurrence('privileged-feria', 'id', saint('simplex'));
expect(result.winner).toEqual({ kind: 'temporal', id: 'id' });
expect(result.commemorations).toEqual([{ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank: 'simplex' }]);
});
it('semiduplex/vigil get nothing here — transfer instead', () => {
const result = decideOccurrence('privileged-feria', 'id', saint('semiduplex'));
expect(result.commemorations).toEqual([]);
expect(result.transfer).toEqual({ candidate: saint('semiduplex'), direction: 'forward' });
});
});
describe('decideOccurrence — privileged-feria-major', () => {
it('is never displaced, same as privileged-sunday — duplex-majus and up are commemorated', () => {
// Verified: St. Mark, Duplex II. classis, only ever commemorated —
// never wins outright — within the Easter Octave.
for (const rank of ['duplex-majus', 'duplex-2-classis', 'duplex-1-classis'] as const) {
const result = decideOccurrence('privileged-feria-major', 'id', saint(rank));
expect(result.winner).toEqual({ kind: 'temporal', id: 'id' });
expect(result.commemorations).toEqual([{ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank }]);
}
});
it('yields nothing short of duplex-majus — transfers instead', () => {
const result = decideOccurrence('privileged-feria-major', 'id', saint('duplex'));
expect(result.winner).toEqual({ kind: 'temporal', id: 'id' });
expect(result.commemorations).toEqual([]);
expect(result.transfer).toEqual({ candidate: saint('duplex'), direction: 'forward' });
});
});
describe('decideOccurrence — ordinary-sunday', () => {
it('duplex or higher wins outright, and the Sunday itself is commemorated', () => {
const result = decideOccurrence('ordinary-sunday', 'post-epiphany-2', saint('duplex'));
expect(result.winner).toEqual({ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank: 'duplex' });
expect(result.commemorations).toEqual([{ kind: 'temporal', id: 'post-epiphany-2' }]);
expect(result.transfer).toBeUndefined();
});
it('simplex stays and is commemorated, not transferred', () => {
const result = decideOccurrence('ordinary-sunday', 'post-epiphany-2', saint('simplex'));
expect(result.winner).toEqual({ kind: 'temporal', id: 'post-epiphany-2' });
expect(result.commemorations).toEqual([{ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank: 'simplex' }]);
expect(result.transfer).toBeUndefined();
});
it('semiduplex gets nothing here — transfers forward', () => {
const result = decideOccurrence('ordinary-sunday', 'post-epiphany-2', saint('semiduplex'));
expect(result.winner).toEqual({ kind: 'temporal', id: 'post-epiphany-2' });
expect(result.commemorations).toEqual([]);
expect(result.transfer).toEqual({ candidate: saint('semiduplex'), direction: 'forward' });
});
it('vigil gets nothing here — transfers backward', () => {
const result = decideOccurrence('ordinary-sunday', 'post-epiphany-2', saint('vigil'));
expect(result.transfer).toEqual({ candidate: saint('vigil'), direction: 'backward' });
});
});
describe('decideOccurrence — privileged-sunday', () => {
it('is never displaced; duplex-majus and up are commemorated', () => {
for (const rank of ['duplex-majus', 'duplex-2-classis', 'duplex-1-classis'] as const) {
const result = decideOccurrence('privileged-sunday', 'advent-1', saint(rank));
expect(result.winner).toEqual({ kind: 'temporal', id: 'advent-1' });
expect(result.commemorations).toEqual([{ kind: 'sanctoral', id: 'x', name: 'St. Ereden', rank }]);
expect(result.transfer).toBeUndefined();
}
});
it('duplex, semiduplex, and simplex all transfer forward — no bare commemoration here', () => {
for (const rank of ['duplex', 'semiduplex', 'simplex'] as const) {
const result = decideOccurrence('privileged-sunday', 'advent-1', saint(rank));
expect(result.commemorations).toEqual([]);
expect(result.transfer).toEqual({ candidate: saint(rank), direction: 'forward' });
}
});
it('vigil transfers backward, same as on an ordinary Sunday', () => {
const result = decideOccurrence('privileged-sunday', 'advent-1', saint('vigil'));
expect(result.transfer).toEqual({ candidate: saint('vigil'), direction: 'backward' });
});
});