aboutsummaryrefslogtreecommitdiff
path: root/test/test_view.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_view.ml')
-rw-r--r--test/test_view.ml52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/test_view.ml b/test/test_view.ml
index a542419..bbed8ee 100644
--- a/test/test_view.ml
+++ b/test/test_view.ml
@@ -140,6 +140,41 @@ let test_day_fields () =
Alcotest.(check bool) "first citation present" true (as_str (get [ "first" ] d) <> "");
Alcotest.(check bool) "gospel citation present" true (as_str (get [ "gospel" ] d) <> "")
+(* W5's own reason for existing: OF cannot reach [View.of_days] through the
+ CLI today ([bin/main.ml]'s [reject_rite_for] refuses [--rite] on every
+ command that would build one), so the only honest way to exercise a
+ THREE-citation day through this path is to drive [View.of_days] directly
+ with a hand-built [Liturgical_day.t] -- which rite actually produced the
+ citations is irrelevant to the render layer; only [citations] itself is.
+ Reuses a real EF day's [temporal]/[observed]/etc. (record update syntax)
+ purely as scaffolding, with its own two real citations discarded and
+ replaced -- nothing here asserts anything EF-specific. Exposed (not
+ [let () = ...] inline) so [test_emit.ml]/[test_ics.ml] can drive the same
+ synthetic day through [Emit_xml]/[Emit_ics] without duplicating it. *)
+let three_citation_view () =
+ let module K = Colitur_kernel in
+ let real = List.hd (days_of_year 2027) in
+ let synthetic =
+ { real with
+ K.Liturgical_day.citations =
+ [ { K.Citation.part = K.Citation.First; reference = "Rom 1:1-7" };
+ { K.Citation.part = K.Citation.Second; reference = "1 Cor 1:3-9" };
+ { K.Citation.part = K.Citation.Gospel; reference = "Ioann 1:1-14" } ] }
+ in
+ let lang = Lazy.force default_lang in
+ V.of_days ~lang ~sigla:(Test_support.default_sigla lang) ~vocab:Rite_ef.Vocab_ef.vocab ~rite:"ef" ~year:2027
+ [ synthetic ]
+
+let test_three_citation_day_exposes_all_three () =
+ let v = three_citation_view () in
+ let d = List.hd (as_list (get [ "days" ] v)) in
+ Alcotest.(check string) "first" "Rom 1:1-7" (as_str (get [ "first" ] d));
+ Alcotest.(check string) "second" "1 Cor 1:3-9" (as_str (get [ "second" ] d));
+ (* "Ioann" -> "John": the stored (Latin) book abbreviation renders through
+ [sigla] the same as [first]/[gospel] always have -- proving [second]
+ shares the identical [Sigla.format] path, not a second, divergent one. *)
+ Alcotest.(check string) "gospel" "John 1:1-14" (as_str (get [ "gospel" ] d))
+
(* Exactly one of the six colour booleans is true on every day of a whole year:
a template that keys a cell colour off them can never get no colour or two. *)
let test_exactly_one_colour_flag () =
@@ -164,6 +199,21 @@ let keys_of = function
| T.Obj kvs -> List.sort compare (List.map fst kvs)
| _ -> Alcotest.fail "expected an object"
+(* W5: EF's own citations are always exactly [First; Gospel]
+ ({!Rite_ef}'s own [citation_shapes]) -- so no EF day's key set should
+ EVER include "second" (or any of the other still-unbuilt parts:
+ "psalm"/"tract"/"alleluia"/"sequence"). Confirms the "absent key, not a
+ present key holding the empty string" half of [View.citation_fields]'s
+ own design, over a whole year rather than one sampled day. *)
+let test_ef_days_never_carry_a_second_key () =
+ let v = view_of 2027 in
+ List.iter
+ (fun d ->
+ List.iter
+ (fun k -> if List.mem k (keys_of d) then Alcotest.failf "%s carries an unexpected key %s" (as_str (get [ "iso" ] d)) k)
+ [ "second"; "psalm"; "tract"; "alleluia"; "sequence" ])
+ (as_list (get [ "days" ] v))
+
let test_padding_and_real_share_key_set () =
let v = view_of 2027 in
let jan = List.hd (as_list (get [ "months" ] v)) in
@@ -318,6 +368,8 @@ let suite =
Alcotest.test_case "padding cells flagged" `Quick test_padding_cells_are_flagged;
Alcotest.test_case "first week flagged" `Quick test_first_week_flag;
Alcotest.test_case "padding and real days share key set" `Quick test_padding_and_real_share_key_set;
+ Alcotest.test_case "EF days never carry a second key" `Quick test_ef_days_never_carry_a_second_key;
+ Alcotest.test_case "three-citation day exposes all three" `Quick test_three_citation_day_exposes_all_three;
Alcotest.test_case "week num_roman and month fields" `Quick test_week_num_roman_and_month_fields;
Alcotest.test_case "week date span" `Quick test_week_date_span;
Alcotest.test_case "single_day agrees with span and cells" `Quick test_single_day_agrees_with_span_and_cells;